5

我只是做了一个简单的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

我试图了解每列代表什么。从这篇文章这个问题中我已经了解到:

  • Column1 显然是提交,
  • Column2 是我感到困惑的地方。我理解HEAD@{0}to 的HEAD@{7}概念。不要得到括号中的部分!. 代表什么(yy, alphabets, hotFix)
  • Column3 是操作,即结帐/拉出消息。

此外,我不确定为什么会有多行相同的提交?是不是因为不同的分支都指向同一个提交并且它们之间没有代码更改?

4

1 回答 1

8

reflog 告诉你如何HEAD移动。有超过三列。Git 文档对此很迟钝。事实证明,这git reflog只是git log某些开关的别名。

git reflog show[默认] 是一个别名git log -g --abbrev-commit --pretty=oneline;

784f2cp3 (yy, alphabets, hotFix) HEAD@{7}: checkout: moving from alphabets to master
  1. 784f2cp3缩写的提交。
  2. (yy, alphabets, hotFix)分支在此提交处开始,就像git log --decorate.
  3. HEAD@{7}此提交相对于 的位置HEAD,由 . 添加-g
  4. checkout运行了什么命令。
  5. moving from alphabets to master人类可读的描述。

(4 和 5 在技术上是同一列。)

这表示您在分支上alphabets并运行git checkout master

此外,我不确定为什么会有多行相同的提交?是不是因为不同的分支都指向同一个提交并且它们之间没有代码更改?

对,就是这样。

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 pullgit pullgit fetch和的组合git merge

于 2018-02-05T19:54:47.853 回答