简而言之,我做了两次git pulls,我需要在我做之前恢复原状。第一次拉动让我前进了至少100次提交,所以我无法猜出我所提交的ID是什么。
有没有办法让我直接撤消拉动或以其他方式找到我今天早上的提交ID?
答案 0 :(得分:3)
git reflog
会向您显示行动记录。每行都以您执行操作的新提交的SHA哈希开始,即提交git移动到。在之前找行<#34;拉&#34;条目和哈希是你拉前的提交。
在此示例中,您将移至&#34; 1234abc&#34;使用git checkout 1234abc
或git checkout HEAD@{2}
。
c831d9e HEAD@{0}: commit: add new feature
fe1c2f8 HEAD@{1}: pull: Fast-forward
1234abc HEAD@{2}: commit: add new data
39c842b HEAD@{3}: checkout: moving from master to feature
aa0b4b7 HEAD@{4}: checkout: moving from master to redis_xvdc
答案 1 :(得分:1)
git reflog
应该打印这样的东西:
859af32 HEAD@{0}: pull: Fast-forward <--- the pull you did
2bbb039 HEAD@{1}: <git command> <--- the point where you want to reset to
....
然后您可以重置为所需的HEAD指针:
git reset (--hard) HEAD@{1}