-2

I'm trying to go back and squash some commits to clean up my history. The issue is I've got some merge commits included in my history, so the rebase fails, even if I do nothing.

For example:

*   A merge branch 'branch' into 'master'
|\
| * B change to line 5 on 'branch'
* | C change to line 5 on 'master'
|/
*   D add a comment
*   E write some code

I want to squash D and E, but I want the merge at commit A to stay exactly the same as it is. However, when I do a git rebase -i E~1 (apparently I need the ~1 in order to pick commit E?), even if I don't make any changes at all, it still fails the rebase with a conflict. Commit A doesn't appear in the editor.

Is it possible to do this kind of rebase, where merge commits are retained as they are without any extra input?

ewok
  • 20,148
  • 51
  • 149
  • 254
  • 1
    Possible duplicate of [Rebasing a Git merge commit](https://stackoverflow.com/questions/4783599/rebasing-a-git-merge-commit) – phd Feb 05 '18 at 19:26

1 Answers1

0

You will have to use --preserve-merges to see merge commits in rebase

git rebase -i --preserve-merges E~1
Ashish Mathew
  • 783
  • 5
  • 20