2011-03-07 76 views

回答

42

而是經過分支的名稱,你可以通過任何提交ID來checkout

git checkout <commit-id> 

See the man page

+0

啊做到了:)我認爲checkout只允許分支名稱。 – xZise 2011-03-07 20:38:00

+2

當你簽出一個非分支對象(通過它的ID或標籤提交)時,你會得到一個分離的頭部。 http://stackoverflow.com/questions/3965676 – Rudi 2011-03-08 07:50:52

+2

當你想回到最新的提交只是使用「git checkout nameOfYourBranch」 – 2013-01-07 11:00:15

4

第1步:取提交的名單:

[Comp:Folder User$ git log 
commit 54b11d42e12dc6e9f070a8b5095a4492216d5320 
Author: author <[email protected]> 
Date: Fri Jul 8 23:42:22 2016 +0300 

This is last commit message 

commit fd6cb176297acca4dbc69d15d6b7f78a2463482f 
Author: author <[email protected]> 
Date: Fri Jun 24 20:20:24 2016 +0300 

This is previous commit message 

commit ab0de062136da650ffc27cfb57febac8efb84b8d 
Author: author <[email protected]> 
Date: Thu Jun 23 00:41:55 2016 +0300 

This is previous previous commit message 
... 

第2步:副本需要提交的哈希,並將其粘貼

git log 

你會在這個例子中得到這樣的列表結賬時使用:

git checkout fd6cb176297acca4dbc69d15d6b7f78a2463482f 

就是這樣。