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 stash
if 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 master
to do an interactive rebase against remote master (assuming your remote is namedorigin
).- Move the temporary commit after the commit that needs to be amended, and tag it
f
for fixup. (Or tag its
if you want to combine the new commit message with the old one.)
Done!
More philosophy: On Sausage Making.
Leave a Reply