Git: How to fix commit during rebase

You should first finish the original rebase, so that you are in a known state with your repository. Then it is quite easy to edit the commit that introduced the error with interactive rebase. Check out the sha1 of the commit you want to fix, then do

git rebase -i <sha1>^

An editor will open containing commits from the HEAD up to the commit you want to fix. Find the commit from the list (it should be the first one), replace the word "pick" with "edit", save and exit editor.

Now you can fix the bug, then do

git commit -a --amend
git rebase --continue

That's it!

Tags:

Git

Rebase