Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to list all files and their commit SHAs in a repo

Tags:

git

My configuration management team asked me to produce a list of all the files included in a release and the SHA of the last commit for each file. I'm trying to figure out how to do that, but I'm not having much success. I tried using the ls-files command and got what looked like promising results (just showing one file as an example):

serenity:ezdcadmin jarsen$ git ls-files app/views/users/edit.html.erb -s 
100644 e34b0f56f0e2e60393e8bffdbc1abe6e5ef0df54 0   app/views/users/edit.html.erb

But when I run the log command for the same file, none of the commit SHAs match the one I got using the ls-files command.

serenity:ezdcadmin jarsen$ git log --oneline app/views/users/edit.html.erb 
9e68c30 Merge differences
bc8accc bootstrap_buttons & sorting/filtering DONE
8aaf2c0 Revised user pages.
0acf2f0 Finished round two of Property pages.
990b262 Finished User flow - list, add, edit, delete
5e3069b Adding edit and delete user pages.

I've spent a lot of time looking for this answer and I kinda need to find it and move on. Any help you could give will be greatly appreciated.

like image 597
jarsenx Avatar asked Dec 05 '25 04:12

jarsenx


1 Answers

Here you go, heavily based on @AndyRoss work:

git ls-files | xargs -I file bash -c "git --no-pager log -1 -z --format=%h file; echo \" file\""
like image 133
Colin Hebert Avatar answered Dec 07 '25 19:12

Colin Hebert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!