How do I exclude a commit from a git pull request?

I have completed a git pull request with my repo. Sometime later, before the pull request was approved, I proceeded to do another commit and push, which was also dropped to pull the request.

Is there a way to remove the last commit from a pull request and how to prevent this from happening in the future?


source to share

1 answer

Yes, you can just reset your branch to a previous commit and force a push: the pull request will be automatically updated.

git checkout yourBranch
git reset --hard yourBranch~
git push --force origin yourBranch


Then, if you want to make such a mistake more complex, delete your branch locally: you won't be checking out or using it by mistake.



All Articles