2012-05-14 24 views
5

如果我ls-tree某棵樹,並得到一個blob和樹的列表,我怎麼能發現最後提交有關這些blob和樹?我正在尋找這樣的事情:如何根據blob/tree hash發現最後一次相關的提交?

$ git ls-tree HEAD 
... 
100644 blob 734713bc047d87bf7eac9674765ae793478c50d3 myfile 
... 
$ git show --commit 734713bc047d87bf7eac9674765ae793478c50d3 
commit 734713bc047d87bf7eac9674765ae793478c50d3 
Author: Scott Chacon <[email protected]> 
Date: Fri Jan 2 18:32:33 2009 -0800 

    fixed refs handling, added gc auto, updated tests 
+1

[這個問題](http://stackoverflow.com/questions/223678/git-which-commit-has-this-blob)被問同樣的事情,並有一些答案,將讓你得到你想要的。當你瀏覽所有提交包含引用blob的提交時,它基本上是一個迭代過程。 – larsks

+1

你能解釋爲什麼這篇文章沒有回答你的問題[哪個提交有這個blob?](http://stackoverflow.com/q/223678/11343) – CharlesB

回答

3

我有點困惑。我不明白你爲什麼需要這樣的東西。但是,我認爲這是你want-什麼

git ls-tree --name-only HEAD | while read file; do git log -n 1 --date=short --pretty="$file, author: %an, commit: %h, date: %ad, msg: '%s'" -- $file; done 
相關問題