[译]git reflog


用法

git reflog

显示整个本地仓储的commit, 包括所有branch的commit, 甚至包括已经撤销的commit, 只要HEAD发生了变化, 就会在reflog里面看得到. git log只包括当前分支的commit.

 

git reflog --relative-date

显示相对时间的commit纪录.

 

讨论

每一次当前HEAD发生改变(包括切换branch, pull, 添加新commit)一个新的纪录就会被添加到reflog.

 

例子

运行git reflog

0a2e358 HEAD@{0}: reset: moving to HEAD~2
0254ea7 HEAD@{1}: checkout: moving from 2.2 to master
c10f740 HEAD@{2}: checkout: moving from master to 2.2

上面的reflog展示了从master到2.2分支, 然后在会到master, 然后在reset到老的commit.

 

如果你发现上面的reset是一次意外是一个错误. 可以使用下面的命令反悔:

git reset --hard 0254ea7

  

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM