Git: remove a past commit

Sometimes, I need to remove a commit from a branch, because I want it in another branch (or already is in another branch) and has nothing to do with the PR.

There is two cases:

  • This is the last commit:
    git reset HEAD~1
  • This is the a commit before:
    git rebase -p --onto SHA^ SHA
Publié le , mis à jour le