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 ?

  • What is the Git branching strategy with agile process?
  • Deny WRITE access to specific branch in gitolite
  • How to handle merges with hgsubversion?
  • Rename TFS 2013 Branch
  • What is the equivalent of branch reset operator (“?|”) found in php(pcre) in C#?
  • Is there a downside to this Mercurial workflow: named branch “dead” head?
  • So changed Git's default editor, now how do i invoke it from Git bash?
  • Create a branch alias and push it
  • EGit marks files as having conflicts but the Merge Tool editor shows no red markers
  • Why does tracking branch create a new remote branch?
  • GitHub repository older than GitHub itself?
  • What is your experience with CI server git support (Windows)?
  • 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.