2012-08-23 73 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