git log VS git reflog

168 阅读1分钟

git log VS git reflog

  • git log 显示所有提交(commit)过的信息
  • git flog 显示所有分支的所有操作记录(比如回退记录,可以看到被删除的 commit ,我们就可以买后悔药,恢复到删除的那个记录)

比如:

  • 当前有两次提交,提交a、提交b

  • 如果执行 git reset --hard HEAD^ 就是回退到 提交a上了

  • git log 只能显示a的提交记录

  • git reflog 能显示:

    • a 提交
    • b提交
    • 回退提交

    也就是显示了所有的操作记录