Let's say I'm six commits ahead of master on my work branch. I've sent out a review, and find out I need to fix something on the 3rd commit. This is my workflow for fixing up the previous git commit:
- Get to a clean state on the work branch. (
git stashif needed)
- Make the necessary changes and commit. For example,
git commit -a -m "Date added fix". This will be a temporary commit.
git rebase -i origin masterto do an interactive rebase against remote master (assuming your remote is named
- Move the temporary commit after the commit that needs to be amended, and tag it
ffor fixup. (Or tag it
sif you want to combine the new commit message with the old one.)
More philosophy: On Sausage Making.