Skip to content

Instantly share code, notes, and snippets.

@alphamarket
Created December 9, 2019 06:42
Show Gist options
  • Save alphamarket/a6349c5d2a4716d3d4bf165076ee27fa to your computer and use it in GitHub Desktop.
Save alphamarket/a6349c5d2a4716d3d4bf165076ee27fa to your computer and use it in GitHub Desktop.
How to add a changed file to an older (not last) commit in Git
# To "fix" an old commit with a small change, without changing the commit message
# of the old commit, where OLDCOMMIT is something like 091b73a:
# Copied from `https://stackoverflow.com/a/27721031/1198291`
git add <my fixed files>
git commit --fixup=OLDCOMMIT
git rebase --interactive --autosquash OLDCOMMIT^ # at here do noting and exit from editor, it will do the job
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment