MeltingDog MeltingDog - 5 months ago 41
Git Question

How to fix 'polluted' pull request on GitHub?

I am working on a large project with a large team. I got a task to edit 1 file and push it to GitHub in it's own branch and create a pull request, which I have done.

However, the branch/pull request has become 'polluted' - it now contains thousands of files and commits, no longer just my 1 commit and 1 file.

Is there anyway I can revert it back to my old commit?


First, check git reflog: you should be able to reset your local PR branch to its old HEAD

Then try again, this time by rebasing your PR branch before force pushing it:

git checkout my-pr-branch
git fetch upstream
git rebase upstream/master
git push --force 

That should push only your own local commit.