Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to discover last related commit based on blob/tree hash?

Tags:

git

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 <[email protected]>
Date:   Fri Jan 2 18:32:33 2009 -0800

    fixed refs handling, added gc auto, updated tests
like image 648
vinnylinux Avatar asked Oct 22 '22 23:10

vinnylinux


1 Answers

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
like image 156
Rifat Avatar answered Oct 27 '22 09:10

Rifat