After running git filter-branch, how do I get a list of old commit SHAs as rewritten by filter-branch to their new corresponding commit SHAs?
For example, something similar to:
b19fd985746c1f060f761d42d353e387bec243fb -> c8ab40ef9bae3b58642a8d1e5b90720d093a60b5
c5ebba1eeb92ca76c0effa32de14178ec7f07db6 -> 4d5a9958b98dbcfa47ce1354bb2af4cc77904639
705f71543235b872ca3e1067538e36d14044429d -> d2aafbd6e5b91955b62dee34f4a0abf0171ba016
Where the left column is the list of original SHAs, and the right column are the new SHAs after being rewritten by filter-branch.
I see that the man page for filter-branch mentions a map function, but I don’t understand whether that’s useful here, or if it is, how to use it.
Thanks for your help!
I had to go poking around the source for
git-filter-branchto 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:(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).