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 ?

  • How to move bugfixes across branches in DVCS?
  • Subversion branch reintegration in v1.6
  • What is a “stale” git branch?
  • When does git refresh the list of remote branches?
  • TFS Branch/Merge meets History View
  • How can I start a clean branch with no ancestry, then commit files progressively?
  • Always use version from merged branch on conflicts
  • Git push complaining about non-fast-forward, even though remote has been pulled
  • How can I push to one url and pull from another using one remote?
  • How to restore Git after fatal file system error?
  • reverting push'd git commit
  • How to use git mv from magit?
  • 2 Solutions collect form web for “undo git pull of wrong branch onto master”

    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.

    In addition to Tim’s answer:
    If you want reset to a specific commit:

    git reflog

    will show you ids of all recent commits

    Then you can perform:

    git reset --hard <specific id>

    to reset to that specific commit.

    Git Baby is a git and github fan, let's start git clone.