Is there a git command that can output for every commit:
- id
- subject
- blobs it created with they path and size (like
git ls-tree -l -r <commit>
but only for created blobs)
Is there a git command that can output for every commit:
git ls-tree -l -r <commit>
but only for created blobs)
One solution based on tig's answer:
Maybe not the best code, but should get you most of the way.
Another useful command when searching for
will show dangling commits. I needed to use this to find a commit a i wiped with an ill-timed reset --hard
But don't take my word for it:
https://www.kernel.org/pub/software/scm/git/docs/git-fsck.html
To get commits (all and output one line per commit):
Then split commits by space with limit of 2 and get every commit id and message
To get blobs created by commit (recurse to subdirs, show merge commits, detect renames and copies, don't show commit id on first line):
A bit of parsing of every line and excluding some of them — and we get list of new blobs and they path for commit
Last is to get blob sizes:
And another time a bit of parsing
You can also get a list of all commits (including the dangling ones) with:
git log --walk-reflogs | grep -E -o '[0-9a-f]{40}'
Include this line in the settings for a new view in gitk (in the last input field, the command to generate additional commits) and you will get a tree that also shows the 'forgotten history' of the project.
Relying on
git rev-list
is not always enough because it(
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:
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 capitialA
in the fifth column) from the loop body.You can get everything but size out of the box. This one is pretty close: