Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raulsouzalima/ac43fc96bd84a8a591ee55f9938216b7 to your computer and use it in GitHub Desktop.
Save raulsouzalima/ac43fc96bd84a8a591ee55f9938216b7 to your computer and use it in GitHub Desktop.
Change old commit on git
git rebase -i @~5 # Show the last 5 commits in a text editor
In the default editor, modify pick to edit in the line whose commit you want to modify.
Make your changes and then commit them with the same message you had before:
$ git commit --all --amend --no-edit #to modify the commit, and after that
$ git rebase --continue #to return back to the previous head commit.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment