git rebase -i: I only want the last commit

I have been working on a branch:

       C1--D1--E1 branch
      /
 A--B--C--D--E--F master

On branch using "git rebase -i master" in a small test repo, I am able to get to here:

 A--B--C--D--E--F--E1 master

The problem is, that when there is an merge conflict git wants me to resolve each of the commits one by one from branch. I have been doing a lot of trial and error and therefore, I have a lot of commits - I just want to merge the working tree on to master without each of the commits.

If I do normal merge I get all the commits.

How would you do this?


To get only one commit, this is what you do :

Currently, your branch has 3 different commits. So, move it to a different branch : Say your branch is called testBranch

git branch newBranch
git reset --hard HEAD~3 (Or as many commits as you have)
git cherry-pick newBranch

Refer this answer for more info : Git - only push up the most recent commit to github

If you now do a git log on 'testBranch', you will find that you have only the last commit (E1). You can simply merge it with master using whatever command you want. I hope this helps.