It’s even easier than in OP’s answer.
git rebase -i <any earlier commit>
. This displays a list of commits in your configured text editor.- Find the commit you want to insert after (let’s assume it’s
a1b2c3d
). In your editor, for that line, changepick
toedit
. - Begin the rebase by closing your text editor (save your changes). This leaves you at a command prompt with the commit you chose earlier (
a1b2c3d
) as if it has just been committed. - Make your changes and
git commit
(NOT amending, unlike mostedit
s). This creates new a commit after the one you chose. git rebase --continue
. This replays the successive commits, leaving your new commit inserted in the correct place.
Beware that this will rewrite history, and break anyone else who tries to pull.