5

If I ls-tree a certain tree and get a list of blobs and trees, how can I discover the last commit related to those blobs and trees? I'm looking for something like this:

$ git ls-tree HEAD
...
100644 blob  734713bc047d87bf7eac9674765ae793478c50d3   myfile
...
$ git show --commit 734713bc047d87bf7eac9674765ae793478c50d3
commit 734713bc047d87bf7eac9674765ae793478c50d3
Author: Scott Chacon <schacon@gmail.com>
Date:   Fri Jan 2 18:32:33 2009 -0800

    fixed refs handling, added gc auto, updated tests
user1338062
  • 11,939
  • 3
  • 73
  • 67
vinnylinux
  • 7,050
  • 13
  • 61
  • 127
  • 1
    [This question](http://stackoverflow.com/questions/223678/git-which-commit-has-this-blob) is asking the same thing, and has some answers that will get you what you want. It's basically an iterative process as you walk through all the commits looking for the one that contains the referenced blob. – larsks May 14 '12 at 15:03
  • 1
    Can you explain why this post doesn't answer your question [Which commit has this blob?](http://stackoverflow.com/q/223678/11343) – CharlesB Jun 18 '12 at 22:25

1 Answers1

3

I'm bit confused. I don't understand why you need something like this. But, I think this is what you 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
Rifat
  • 7,628
  • 4
  • 32
  • 46