Sometimes the log message for a git commit will mention the SHA of other commits. This happens in the suggested log message for git revert
and you also may add it by hand ('fixed bug introduced in abcd0123').
When rebasing, the SHAs of commits change. Is there a way I can automatically fix up the log messages to have the new SHAs? In general, this might not be possible in 100% of cases (a commit might disappear altogether, be squashed, etc). But 90% of the time a simple rebase leaves a one-to-one correspondence between the original and the rebased commits, so it should be possible to remap the SHAs in log messages.
I have tried git rebase --verbose
, which I hoped would print something like
Applying: My log message here.
old commit was 01234
new commit is abcde
I could then use that to manually fiddle the log messages (with a further rebase... which would in turn change the SHAs... so it would be awkward, but nonetheless possible). But as far as I can tell --verbose
doesn't print more information than the normal mode.
Is there some magic tool which will rebase and rewrite the log messages for me? In the absence of ponies, can I convince git rebase
to print more information about old and new SHAs so I can do the job myself?
You can use
git patch-id
to find commits that apply the same changes, the most brute-force method would beto find every set of commits in your repo that apply similar patches. A bit of
git log --grep=
applied to the results, and perhaps some restraint on your rev-list args, should get you where you want to go.On GNU/anything replacing the uniq with
groups the commit ids for you. You could use
join
or some more awking to achieve the same effect elsewhere.You can add git notes to a commit (or to any object), that might help if you're trying to distribute warnings about what happened.