Reputation: 155
I want to show filenames in a git repository together with the most recent commit hash in one line, separated by an equal character. If some files belong to the same commit they should be listed on separate lines.
Example:
file1.txt=0c6347311613be2ec6fb61c43f36e87a6f3f998a
file2.txt=0b4180564ddc676a3a2bb4d2c4111fb08adc9d09
file3.txt=0b4180564ddc676a3a2bb4d2c4111fb08adc9d09
file4.txt=0b4180564ddc676a3a2bb4d2c4111fb08adc9d09
and so on
How can i achieve that with "git log"? (there is no format specifier for the filename in the "pretty" formats).
I am running on windows, so i am not sure if i can use other tools like AWK and such tools.
Upvotes: 0
Views: 322
Reputation: 30156
It can't be done in a single shot.... but it can be done with a bash 1-liner:
git ls-tree -r --name-only HEAD | while read file; do echo $file"="$( git log --pretty=%H -n 1 -- $file); done
Upvotes: 1