Reputation: 379
I would like to get a list of all files in my branch, preferably in a tree view, together with the hash of the commit they have last been modified in (i.e. not the hash of the file itself but of the commit). Is there a neat git-command to do this, or do I really have to crawl through the log?
This question is related to How do I find the most recent git commit that modified a file? but I want to get a list of all files, for example:
6f88a51 abc.h
3f5d6fb abc.cpp
3f5d6fb bcd.h
1964be2 bcd.cpp
...
Upvotes: 11
Views: 4943
Reputation: 56412
for i in $(find -type f | grep -v '.git');
do echo -n "$i - ";
git log --pretty="format:%h" -1 $i | cat;
echo;
done
That should do the trick, on bash
Upvotes: 3
Reputation: 4883
Command:
$ git ls-files -z \
| GIT_PAGER= xargs -0 -L1 -I'{}' git log -n 1 --format="%h {}" -- '{}'
f5fe765 LICENSE
0bb88a1 README.md
1db10f7 example/echo.go
e4e5af6 example/echo_test.go
...
Notes:
git ls-files
lists all files added to git recursively (unlike find
, it excludes untracked files and .git
)xargs -L1
executes given command for every input argument (filename)xargs -I{}
enables substitution of {}
symbol with input argument (filename)git ls-files -z
and xargs -0
changes delimiter from \n
to \0
, to avoid potential problems with white-spaces in filenamesGIT_PAGER
prevents git log
from piping it's output to less
Upvotes: 10
Reputation: 141946
You can simply use the ls-tree command
git ls-tree HEAD
This will show you the latest files with their hashes.
Upvotes: 0