10

I wanted to reword a commit in git so I did a git rebase -i 00112233 or something similar and I get merge conflicts without making any changes to the commits that will be applied. I enter the merge command, the editor pops up, I accept what's there and there's a merge conflict.

My understanding of git rebase -i is that HEAD is set to 00112233 and then the commits after 00112233 (which are already consistent since they've been applied to get to the current state) are applied in the order specified in the editor (which I haven't changed in this case). I can't figure out how that process would lead to a merge conflict.

What are any ways such a situation can occur?

mrmcgreg
  • 2,754
  • 1
  • 23
  • 26

1 Answers1

7

If the history in question is not linear, you may have to reapply the conflict resolution you employed when you first merged. To iilustrate, if history is:

C:\Temp\TestRepo>git log --graph  --oneline
*   3fc0537 Merge branch 'branch'
|\
| * 79e29f9 branch
* | 0de3658 master
|/
* edead94 Initial revision

And the merge commit 3fc0537 contained a conflict:

C:\Temp\TestRepo>git log -1
commit 3fc053701a53a30a01469f560ad5057eab74d126
Merge: 0de3658 79e29f9
Author: Edward Thomson <ethomson@edwardthomson.com>
Date:   Thu Feb 6 17:55:59 2014 -0800

    Merge branch 'branch'

    Conflicts:
        file.txt

Then rebasing off edead94 will produce a merge conflict.

Edward Thomson
  • 74,857
  • 14
  • 158
  • 187
  • Thanks! Do you know if there is a way to say 'just resolve the conflicts the way that they were resolved before'? – mrmcgreg Feb 07 '14 at 06:43
  • It looks like `--preserve-merges` is relevant here. This question: http://stackoverflow.com/questions/15915430/what-exactly-does-gits-rebase-preserve-merges-do-and-why has a pretty good answer. – mrmcgreg Feb 07 '14 at 14:11
  • 2
    @testuser Also, to re-resolve conflicts, you might checkout the `git rerere` tool: https://www.kernel.org/pub/software/scm/git/docs/git-rerere.html – Edward Thomson Feb 07 '14 at 16:21