git reflog(转载)
原文出处:http://www.cnblogs.com/irocker/p/git-reflog.html
用法
git reflog |
显示整个本地仓储的commit, 包括所有branch的commit, 甚至包括已经撤销的commit, 只要HEAD发生了变化, 就会在reflog里面看得到. git log只包括当前分支的commit.
|
1
|
git reflog --relative-date |
显示相对时间的commit纪录.
讨论
每一次当前HEAD发生改变(包括切换branch, pull, 添加新commit)一个新的纪录就会被添加到reflog.
例子
运行git reflog
0a2e358 HEAD@{0}: reset: moving to HEAD~20254ea7 HEAD@{1}: checkout: moving from 2.2 to masterc10f740 HEAD@{2}: checkout: moving from master to 2.2 |
上面的reflog展示了从master到2.2分支, 然后在会到master, 然后在reset到老的commit.
如果你发现上面的reset是一次意外是一个错误. 可以使用下面的命令反悔:
git reset --hard 0254ea7 |

浙公网安备 33010602011771号