2016-04-25 39 views
0

如何從diff輸出獲取提交的SHA?如何從差異輸出獲取提交的SHA?

例如我喜歡diff的二進制文件,的git show COMMIT輸出爲:

diff --git a/0_prospektusok/FAR_feltetdiszek/feltetdisz_prospektus.xls b/0_prosp 
index 9993010..707c169 100644 
Binary files a/0_prospektusok/FAR_feltetdiszek/feltetdisz_prospektus.xls and b/0 

git show 9993010示出了終端中的文件,但如果將它重定向到 文件和開口使用MS Excel,它包含垃圾。

git checkout 9993010fatal: reference is not a tree: 9993010

如何結算ab的版本?

+0

http://stackoverflow.com/questions/19224476/how-does-index-f2e4113-d4b9bfc-100644-in-git-的可能的複製diff-corresponding-to-sha1-id-in-gi(我不想把它作爲一個重複關閉) – torek

回答

1

如果您要結算整個回購,因爲它是在COMMIT之前使用git checkout COMMIT~
如果要保留工作副本和所有文件,但只將文件更新爲COMMIT之前的狀態,請使用git checkout COMMIT~ -- 0_prospektusok/FAR_feltetdiszek/feltetdisz_prospektus.xls
爲了解釋爲什麼git checkout 9993010沒有工作,閱讀答案How does "index f2e4113..d4b9bfc 100644" in git diff correspond to SHA1 ID in gitk?

+0

我怎樣才能找到引入'9993010'的提交的SHA? – bimlas

+0

這不是唯一可識別的,因爲這只是具有可能出現在任何提交量中的文件內容的blob。您可以使用http://stackoverflow.com/questions/223678/which-commit-has-this-blob答案中的其中一個腳本獲取包含blob的所有提交。但是當你做了'git diff COMMIT',你後面的是'COMMIT ~'。 – Vampire