~并且^是可用于指定提交历史中的任何祖先的运算符。
让我们从一张图开始:
* aa (HEAD, master) commit
* bb merged branch `some/feature` into master
|\
| * cc (some/feature) feature: completed
| * dd feature: wip
| * ff feature: start
* | gg some fix on master
|/
* hh some commit on master
在某些情况下,你可以有章鱼合并提交,它可能有xx^3, xx^4... 父母。
通过组合运算符,您可以“导航”到任何祖先提交。
例如,从 开始aa,一种到达方式ff是:
aa~^2~2
# some other ways to describe a path to reach `ff` :
aa^^2~2 # to reach the first parent, ~ or ^ are equivalent
aa~^2~~ # ~2 is the same as ~~
aa^^2^^
...
一般来说,你不能切换~和^序列,因为它们不会指向同一个提交。
例如 :
aa~^2 # points at cc
aa^2~ # does not exist
任何指向提交的内容都可以是aa,bb或cc以上:
HEAD, 一sha1, some/branch, some/tag...
- git已知的其他一些参考:(
stash@{0}存储中的项目),HEAD@{3}(参考日志中的元素HEAD),master@{2}(master分支参考日志中的元素)
- ...