I had to go poking around the source for git-filter-branch
to work this one out. It's not documented (as far as I can tell), but the old commit ID is explicitly exported as $GIT_COMMIT
. This worked for me:
$ git filter-branch --your-filters-here --commit-filter 'echo -n "${GIT_COMMIT}," >>/tmp/log; git commit-tree "$@" | tee -a /tmp/log' your-branch-here
[...]
$ cat /tmp/log
70d609ba7bc58bb196a2351ba26afc5db0964ca6,d9071b49743701c7be971f76ddc84e76554516c7
0d1146dcabc00c45fb9be7fe923c955f7b6deb50,cb6813f9aca5e5f26fcc85007c5bb71552b91017
[...]
(That file, of course, has the format <original commit hash>,<new commit hash>
.)
I'm kind of curious what your intentions are with using this though. It doesn't seem like information you'd need to typically know if you're using filter-branch the "right" way (i.e., not manipulating existing published history).