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, change pick
to edit
.
- 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 most edit
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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…