4 ms·
I used to do the process you describe, but have greatly improved it using autosquash: * Add your changes to the index * git commit --fixup SHA, where SHA is th
by erso 14y ago
I used to do the process you describe, but have greatly improved it using autosquash:
* Add your changes to the index
* git commit --fixup SHA, where SHA is the commit you want to fixup into
* git rebase -i --autosquash, now or later
When you commit with --fixup, Git will make a commit with a message that begins with fixup! and continues with the message of the SHA you gave it. When you enter the interactive rebase, Git will automatically have moved the fixup commit just below the commit it's going to be fixup'd into.
With this method you don't have to manage moving around the fixup commits, or use a system to tell you where they need to go. I used to do messages like "git commit -m 'f into a98oe6e'", which works until you do a rebase and the SHAs change.
You can also enable autosquash in your gitconfig (git config --global rebase.autosquash true) so you don't need to pass --autosquash when doing the interactive rebase.