Skip to content

Instantly share code, notes, and snippets.

@JuanequeX
Created October 25, 2022 03:48
Show Gist options
  • Save JuanequeX/14a82126e464f2c7a7445ab7a8f35db7 to your computer and use it in GitHub Desktop.
Save JuanequeX/14a82126e464f2c7a7445ab7a8f35db7 to your computer and use it in GitHub Desktop.

To modify commit bbc643cd, run:

$ git rebase --interactive 'bbc643cd^'

the caret ^ at the end of the command, because you need actually to rebase back to the commit before the one you wish to modify.

In the default editor, modify pick to edit in the line mentioning bbc643cd.

Save the file and exit. git will interpret and automatically execute the commands in the file. You will find yourself in the previous situation in which you just had created commit bbc643cd.

At this point, bbc643cd is your last commit and you can easily amend it. Make your changes and then commit them with the command:

$ git commit --all --amend --no-edit

After that, return back to the previous HEAD commit using:

$ git rebase --continue

To finish push it using force

$ git push origin <your-branch> --force-with-lease
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment