git - git reflog 中的第二列是什么?

标签 git git-reflog

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

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

yyalphabetshotFixmaster 都在同一提交上。在它们之间进行检查只是更改下一次提交将移动哪个分支头。

其他可能是内部 HEAD 移动,当您运行 git pull 时发生。 git pullgit fetchgit merge 的组合。

关于git - git reflog 中的第二列是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48630217/

相关文章:

git checkout 上一条

git - Windows 下自动提交 git

git - 如何防止在 .gitignore 中匹配子目录?

git - 列出压缩的提交

git - 你能备份 git reflog 吗?关于防止代码丢失的最佳实践的建议

git - 恢复被 git pull 覆盖的更改

git - 无限期地保持 Git Reflog?

Git:当用户名包含 "@"符号时从 HTTP 存储库克隆

git - visual studio 2013如何记住远程git/tfs仓库和本地路径之间的映射?

windows - Windows 批处理文件中的 LF 与 CRLF 行结尾