3 ms·
This works great but can only be used to amend HEAD. If you want to amend a commit that's HEAD~1 or further back, you need to either use the fixup strategy I me
by erso 14y ago
This works great but can only be used to amend HEAD. If you want to amend a commit that's HEAD~1 or further back, you need to either use the fixup strategy I mentioned above, or, if you really want to use --amend:
* git rebase -i SHA-to-be-amended~1
* select SHA-to-be-amended for edit
* make your changes
* git commit --amend -CHEAD (This takes the message from HEAD without presenting you with the editor. If you wanted to edit the message, use -cHEAD.)
* git rebase --continue
It's good to know when and how to use both. The fixup strategy is much quicker and doesn't require you to do the rebase immediately. I will sometimes stack a few fixup commits and just do the interactive rebase (with autosquash) later.