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
...
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With