Undo git fast forward merge

I have this situation :
Working on some testBranch for some time and I wanted to sync with master so I did
git checkout testBranch and
git merge master/testBranch

So now my branch is synced with master but then I found out that I want to undo that merge and problem is that merge is done with fast forward and now my commit history is mixed with master commits and testBranch commits and I don’t know how to revert to state before merge on my testBranch.

  • git merge with --no-ff and --squash
  • When to use the '--no-ff' merge option in Git
  • Git: Prevent commits in master branch
  • What are the differences between `--squash` and `--no-ff --no-commit`?
  • How do I show the files that where merged with a no fast-forward in Git?
  • Git pull only certain number of commits
  • Thanks for any help

  • ignore all _notes directories with GIT
  • How Can I View All Files Changed on a Branch in Git
  • What git setup and commands can help managing private content on a public Github?
  • Swap “Latest release” on github
  • What is the state of distributed bug tracking?
  • git: move stash to repository in another directory
  • 2 Solutions collect form web for “Undo git fast forward merge”

    git reflog show testBranch

    should show the Fast-forward merge as last item ({0}).
    After making sure this is the case, checkout testBranch and then just do

    git reset --keep testBranch@{1}

    to revert to the previous state.

    If you know of a revision in which you want your local testBranch, it is as simple as:

    git checkout testBranch
    git reset --hard <revision>

    If you have changes mixed in like (oldest on top):


    You could:

    git checkout testBranch
    git reset --hard <point>
    git cherry-pick <your_change_a>
    git cherry-pick <your_change_b>
    Git Baby is a git and github fan, let's start git clone.