OverTheEdge OverTheEdge - 4 years ago 129
Git Question

undo git pull of wrong branch onto master

I have pulled from a different branch from the remote. The 2 branches are different yet the merge happened silently on my current branch. I am currently working on the "master" branch locally, and it has been updated with the changes of the remote branch - "FE_Changes".

How do I remove the effects of the "FE_Changes" branch from my master branch ?

Answer Source

git reset --hard HEAD~1

This will nuke the most recent commit on your local branch. Assuming your pull strategy is merge, then there should only be one rogue commit on your local master branch. You mentioned that "the merge happened silently," so this should work in your case. Once you have fixed the master branch, you may pull again, this time making sure you pull from the correct remote branch.

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