以下命令揭示了我刚才所做的事情:
Z:\www\gg\web\tests\sample-repo-cloned>git log --all --source --graph
* commit ce7ae79a2b993b780002dbc5eac650fa49427df0 refs/heads/qux
| Author: myname <myemail@gmail.com>
| Date: Sun Sep 25 00:24:42 2011 +0300
|
| qux another
|
* commit ef2ea79f40d8e77e47cba31954ef2093c534cc17 refs/heads/qux
| Author: myname <myemail@gmail.com>
| Date: Sun Sep 25 00:15:56 2011 +0300
|
| qux
|
Z:\www\gg\web\tests\sample-repo-cloned>git branch
* master
qux
Z:\www\gg\web\tests\sample-repo-cloned>git checkout qux
Switched to branch 'qux'
Z:\www\gg\web\tests\sample-repo-cloned>notepad2 qux.txt
Z:\www\gg\web\tests\sample-repo-cloned>git add qux.txt
Z:\www\gg\web\tests\sample-repo-cloned>git commit -m "qux more stuff"
[qux 1d18327] qux more
1 files changed, 2 insertions(+), 1 deletions(-)
Z:\www\gg\web\tests\sample-repo-cloned>git log --all --source --graph
* commit 1d183278e78b8896d882822dacb4aad5bb8cf1bd refs/heads/qux
| Author: myname <myemail@gmail.com>
| Date: Sun Sep 25 00:39:06 2011 +0300
|
| qux more
|
* commit ce7ae79a2b993b780002dbc5eac650fa49427df0 refs/remotes/origin/qux
| Author: myname <myemail@gmail.com>
| Date: Sun Sep 25 00:24:42 2011 +0300
|
| qux another
|
* commit ef2ea79f40d8e77e47cba31954ef2093c534cc17 refs/remotes/origin/qux
| Author: myname <myemail@gmail.com>
| Date: Sun Sep 25 00:15:56 2011 +0300
|
| qux
|
我的问题是:为什么前两个提交会将其“来源”从refs/heads/qux
更改为refs/remotes/origin/qux
?他们在第三次提交后就这样做了。我不明白这一点。这个“来源”背后的逻辑是什么?它似乎在随意改变。
答案 0 :(得分:2)
--source
的{{1}}参数只是有点令人困惑,我很害怕。这意味着每个提交都将显示为找到它的引用 - 这并不意味着它将列出包含该提交的所有引用。在您的情况下,包含所有包含该提交的引用的类似选项的假设输出将是:
git log
...您可以通过* commit 1d1832 refs/heads/qux
| Author: myname <myemail@gmail.com>
| Date: Sun Sep 25 00:39:06 2011 +0300
|
| qux more
|
* commit ce7ae7 refs/heads/qux refs/remotes/origin/qux
| Author: myname <myemail@gmail.com>
| Date: Sun Sep 25 00:24:42 2011 +0300
|
| qux another
|
* commit ef2ea7 refs/heads/qux refs/remotes/origin/qux
| Author: myname <myemail@gmail.com>
| Date: Sun Sep 25 00:15:56 2011 +0300
|
| qux
浏览历史记录或尝试使用gitk --all
等来确认。
所以,所有发生的事情是,当你第二次运行git branch -a --contains ef2ea7
时,它首先检查了git log
远程跟踪分支,然后检查了你的origin/qux
分支重新开始工作。至于为什么这两个调用之间的顺序不同,我恐怕不确定。
由于您尚未通过qux
或git push
更新远程跟踪分支,因此远程跟踪分支已落后。