2012-03-21 94 views
1

我是新來的開源和git。我一直在學習git併爲項目做出貢獻。我已經被賦予了在過去的提交中研究它的git歷史的任務,然後從代碼中學習(因爲該項目現在已經發展)。 我知道git存儲了項目的整個歷史。那麼有沒有辦法在本地恢復到舊版本的項目。我不打算或有權及時恢復其遠程回購,我只想將本地副本恢復到較舊的提交。如何查看項目的git歷史並恢復到較舊的提交?

+0

恢復或只是結賬? – 2012-03-21 16:40:11

回答

4

gitk顯示提交的圖形歷史記錄,每個提交都有一個唯一的SHA哈希標識符。

您可以使用git checkout {commit id}簽出更早的版本。你讓Git的恢復使用這些命令的早期版本:

# reset the index to the desired tree 
git reset 56e05fced 

# move the branch pointer back to the previous HEAD 
git reset --soft [email protected]{1} 

git commit -m "Revert to 56e05fced" 

# Update working copy to reflect the new commit 
git reset --hard 

Revert to a commit by a SHA hash in Git?

+0

'git log'或'git log --graph'也會顯示提交歷史記錄。 – 2012-03-21 13:41:51

0

聽起來像是你應該使用「混帳重置」,而不是「混帳復歸」刪除最近的變化和重置前提交。

到列表上提交你可以使用 git的日誌 commit ss

那麼一旦你已經找到了承諾要恢復,使用第9個 字符,在git的復位CMD喜歡承諾SHA: git reset --hard fbcc6aa00