我偶尔会不小心写git checkout ...,这让我处于一个独立的头状态.我想知道为什么.这是"点故事":
> git checkout .
# checks out current directory
> git checkout ..
# Checks out parent directory, if in repository.
> git checkout ...
# Puts into detached head state?
> git checkout ....
error: pathspec '....' did not match any file(s) known to git.
Run Code Online (Sandbox Code Playgroud)
lar*_*sks 48
这是此语法的简并形式,在gitrevisions(7)手册页中进行了描述:
<rev1>...<rev2>
Include commits that are reachable from either <rev1> or <rev2> but
exclude those that are reachable from both. When either <rev1> or
<rev2> is omitted, it defaults to HEAD.
Run Code Online (Sandbox Code Playgroud)
注意最后一位,"当省略<rev1>或<rev2>省略时,它默认为HEAD".这意味着写作...相当于HEAD...HEAD.在git checkout此使用时,最终会评估HEAD的提交ID.也就是说,你只是在做:
git checkout HEAD^{commit}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1735 次 |
| 最近记录: |