我只是做了一个简单的 git reflog
这是我得到的前几行:
column1 Column2 Column3
2797a1d4 (HEAD -> master, upstream/master) HEAD@{0}: checkout: moving from master to master
2797a1d4 (HEAD -> master, upstream/master) HEAD@{1}: pull upstream master: Fast-forward
a461a29f HEAD@{2}: checkout: moving from master to master
a461a29f HEAD@{3}: reset: moving to HEAD
a461a29f HEAD@{4}: pull upstream master: Fast-forward
784f2cp3 (yy, alphabets, hotFix) HEAD@{5}: checkout: moving from yy to master
784f2cp3 (yy, alphabets, hotFix) HEAD@{6}: checkout: moving from master to yy
784f2cp3 (yy, alphabets, hotFix) HEAD@{7}: checkout: moving from alphabets to master
我试图了解每一列代表什么。从 this post 读取和 this question我已经学会了:
- Column1 显然是提交,
- 第 2 列让我感到困惑。我了解
HEAD@{0}
到HEAD@{7}
的概念。 不要获取括号中的部分!。(yy, alphabets, hotFix)
代表什么? - 第 3 列是操作,即 checkout/pull 消息。
此外,我不确定为什么同一提交有多行?是因为不同的分支都指向同一个提交,它们之间没有代码变化吗?
最佳答案
reflog 告诉您 HEAD
是如何移动的。有超过三列。 Git 文档对此很迟钝。原来 git reflog
只是 git log
的别名,带有一些开关。
git reflog show
[the default] is an alias forgit log -g --abbrev-commit --pretty=oneline;
784f2cp3 (yy, alphabets, hotFix) HEAD@{7}: checkout: moving from alphabets to master
784f2cp3
缩写提交。(yy, alphabets, hotFix)
此提交的分支头,就像git log --decorate
一样。HEAD@{7}
此提交相对于HEAD
的位置,由-g
添加。checkout
运行了什么命令。moving from alphabets to master
人类可读的描述。
(4 和 5 在技术上是同一列。)
这表示您在分支 alphabets
上并运行了 git checkout master
。
Additionally I'm uncertain as to why there is multiple lines of the same commit? Is it because different branches are all pointing to the same commit and there is no code changes between them?
是的,完全正确。
784f2cp3 (yy, alphabets, hotFix) HEAD@{5}: checkout: moving from yy to master
784f2cp3 (yy, alphabets, hotFix) HEAD@{6}: checkout: moving from master to yy
784f2cp3 (yy, alphabets, hotFix) HEAD@{7}: checkout: moving from alphabets to master
yy
、alphabets
、hotFix
和 master
都在同一提交上。在它们之间进行检查只是更改下一次提交将移动哪个分支头。
其他可能是内部 HEAD
移动,当您运行 git pull
时发生。 git pull
是 git fetch
和 git merge
的组合。
关于git - git reflog 中的第二列是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48630217/