Posted over 10 years ago. Visible to the public.
Git: Amending older commits
Lets say you need to make a change to a commit
OLD_COMMIT, but this is not the most recent. If you have neither pushed nor merged it, you can do this:
- Make a new commit now, with a message like "fix".
- Do a
git rebase -i OLD_COMMIT~
- In the editor window that opened, move the "fix" commit directly after the one you want to amend (so it should be the second from the top), and mark it as "fixup". Save the file.
- If there are conflicts, solve them, add them, and do
git rebase --continue