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.

  • Will Github count contributions from branches merged by -no-ff merge (not fast forward)?
  • Enforce no-ff merge across a team
  • Reproducible android builds with git with fast forward merges
  • Can I make fast forwarding be off by default in git?
  • Feature branch with or without fast-forward merge?
  • What is the difference between `git merge` and `git merge --no-ff`?
  • Thanks for any help

  • “git gc” says fatal: failed to write ref-pack file
  • How do I list everyone who has ever committed to a file in Git?
  • GIT change Base/Root Folder
  • Git - rm equivalent for “add .”?
  • Git: rename directory (case-only) on Windows
  • Telling git to ignore symlinks
  • 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):

    <point>
    <your_change_a>
    <change_from_someone_else>
    <your_change_b>
    <testBranch>
    

    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.