2014-11-06 50 views
1

概括地说,我做了两个混帐拉,我需要恢复到之前,我都做了。第一次拉我带来了至少100个提交,所以我不能猜到我在提交什么提交ID。我需要恢复我的最后两个“混帐拉,”我不知道任何关于提交我需要

有什么办法,我直接撤消拉或以其他方式查找提交ID我是今天早上?

+1

您是否尝试过'混帐reflog'? – 2014-11-06 00:35:45

+0

它似乎很接近,但它不提供我需要的信息。我在那里看到的唯一提交ID太新了,无法满足我的需求。我看到一个“拉:快进”,这可能是我需要恢复的一个,但它没有给出任何ID – Dan 2014-11-06 00:46:33

+0

我正在阅读日志错误,我有我需要的东西。谢谢。 – Dan 2014-11-06 00:52:55

回答

3

git reflog会告诉你的操作的历史记录。每一行都以作为操作结果的新提交的SHA哈希开始,即提交git移动到。在之前查找行,“拉”条目以及该哈希表是你在提交之前进行的提交。

在这个例子中,你会移动到“1234abc”与git checkout 1234abcgit checkout [email protected]{2}

c831d9e [email protected]{0}: commit: add new feature 
fe1c2f8 [email protected]{1}: pull: Fast-forward 
1234abc [email protected]{2}: commit: add new data 
39c842b [email protected]{3}: checkout: moving from master to feature 
aa0b4b7 [email protected]{4}: checkout: moving from master to redis_xvdc 
1
git reflog 

应打印是这样的:

859af32 [email protected]{0}: pull: Fast-forward <--- the pull you did 
2bbb039 [email protected]{1}: <git command> <--- the point where you want to reset to 
.... 

然后你就可以恢复到所需的HEAD指针:

git reset (--hard) [email protected]{1} 
+3

与往常一样,注意'reset --hard':它会覆盖整个工作目录,包括尚未添加到索引中的脏文件,而不会询问。这是一个很好的工具,但不要使用它,除非你知道它的作用。 – amalloy 2014-11-06 01:36:29