我认为这些应该是两个不同的HEADS,那么为什么它们对应相同的sha值,即2aad8cb ......
git reflog
2aad8cb HEAD@{0}: checkout: moving from master to xxx_master
2aad8cb HEAD@{1}: clone: from git@github.com:xxx/xxx.git
答案 0 :(得分:2)
当您首次通过git branch newbranch
或git checkout -b newbranch master
创建新分支时,newbranch
将指向与分支点完全相同的提交(无论HEAD在第一个示例中是什么,或{在第二个中{1}}。因此,例如,master
和master
具有相同的SHA是正常的。当您在任一分支上创建新提交时,该分支将指向新提交,该提交将以前的值作为其父级(过度简化以避免讨论合并等)。
答案 1 :(得分:1)
这是正常行为。 reflog记录了过去的位置以及过去的分支。这样做
git checkout master
git checkout experiment
git checkout master
git checkout experiment
git checkout master
git checkout experiment
将以
结束2aad8cb HEAD@{0}: checkout: moving from master to experiment
d8cbf4b HEAD@{1}: checkout: moving from experiment to master
2aad8cb HEAD@{2}: checkout: moving from master to experiment
d8cbf4b HEAD@{3}: checkout: moving from experiment to master
2aad8cb HEAD@{4}: checkout: moving from master to experiment
d8cbf4b HEAD@{5}: checkout: moving from experiment to master
在reflog中。您可以看到重复的值。
在这里,我曾多次使用git checkout -
来检查SHA-1(分离的头部)和主机:
5016d9e (HEAD, origin/master, master) HEAD@{0}: checkout: moving from 5016d9e82379923c21268e73e4dad3122a5639ac to master
5016d9e (HEAD, origin/master, master) HEAD@{1}: checkout: moving from master to 5016d9e82379923c21268e73e4dad3122a5639ac
5016d9e (HEAD, origin/master, master) HEAD@{2}: checkout: moving from 5016d9e82379923c21268e73e4dad3122a5639ac to master
5016d9e (HEAD, origin/master, master) HEAD@{3}: checkout: moving from master to 5016d9e82379923c21268e73e4dad3122a5639ac
5016d9e (HEAD, origin/master, master) HEAD@{4}: checkout: moving from 5016d9e82379923c21268e73e4dad3122a5639ac to master
您可以看到相同的SHA1条目重复。