Is there a git command that can output for every commit:
git ls-tree -l -r &l
Relying on git rev-list
is not always enough because it
List[s] commits that are reachable by following the parent links from the given commit(s) [..]
(git help rev-list
)
Thus it does not list commits that are on another branch and it does not list commits that are not reachable by any branch (perhaps they were created because of some rebase
and/or detached-head actions).
Similarly, git log
just follows the parent links from the current checked out commit. Again you don't see commits referenced by other branches or which are in a dangling state.
You can really get all commits with a command like this:
for i in `(find .git/objects -type f |
sed 's@^.*objects/\(..\)/\(.\+\)$@\1\2@' ;
git verify-pack -v .git/objects/pack/*.idx |
grep commit |
cut -f1 -d' '; ) | sort -u`
do
git log -1 --pretty=format:'%H %P %ai %s%n' $i
done
To keep it simple, the loop body prints for each commit one line containing its hash, the parent hash(es), date and subject. Note, to iterate over all commits you need to consider packed and not-yet packed objects.
You can print the referenced blobs (and only created ones) by calling git diff-tree $i
(and greping for capitial A
in the fifth column) from the loop body.