2012-08-23 72 views
4

我想回去提交一个。我能怎么做?git如何退回提交

$ git reflog 
9b2a45e [email protected]{0}: reset: moving to HEAD~1 
0c54f19 [email protected]{1}: reset: moving to HEAD~1 
b9c157d [email protected]{2}: commit: updated from online 
0c54f19 [email protected]{3}: commit: add img from download folder 
9b2a45e [email protected]{4}: commit: add images 
6fa6e34 [email protected]{5}: clone: from [email protected]:starpix/dojo.git 


$ git reset --hard HEAD~1 
HEAD is now at 9b2a45e add images 

我想回到“从网上更新”。我怎么能够?

回答

5

git checkout b9c157d检出sha所代表的提交,以b9c157d开头 - 您提到的提交。

1

如果您有该特定提交的提交ID,那么此语法将为您执行。

git checkout commit_name在提交名称传递提交ID,如果你不想然后再结帐恢复,提交将通过这一个git revert commit_name做。

6

你可以只动脑子前页到b9c157d

git reset --hard b9c157d 
+0

复位命令是使用了理想的,所以你仍然可以得到您的分支来跟踪更改。你可以使用--soft或者--mixed开关来防止你在舞台或者工作区域跳过变化,否则--hard已经足够好了 – maxmelbin