MeltingDog MeltingDog - 1 year ago 78
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download