gitrebaseconflict

Why does a simple rebase have weird conflicts?


Premise: I've never really worked seriously with rebase, I've always done some super easy jobs, without really never trying to understand exactly what and why was going on. But now I have to.

I need to delete from the imgui-save branch this commit, which, unfortunately, is not the last one.

Therefore I tried to rebase with git rebase --onto commitID^ commitID. The commit to delete is pretty easy (it's just a jar and a couple of line in the Gradle build script), in the way that it doesn't interact (almost) at all with the successive commits, however, I got conflicts anyway.

For example: what is strange is that the first conflict appears coming from a previous commit in time from a different time-line: c943eb91 with files which have nothing to do with it: enter image description here

I also tried to use Idea Gui, choosing "rebase from here" on the commit to delete, but I end up with the same conflicts

Also, when I'm trying to resolve them, what does exactly mean the window on the left and the one on the right (I'm using Intellij Idea)? I guess the one on the left is the status at the c943eb91 commit, but where does the one on the right "Already rebased commits" comes from, time-wise?

enter image description here

Because I'd assume Git attempting to rebase commit after commit of the same time-line starting from the commit after the dropped one..


Solution

  • git does not rebase merges by default. If there are merges involved in the to-be-rebased history where there have been changes added on the fly (it can be any change, but think particularly in terms of conflict resolutions) then you will be missing those changes, which could very well explain what you are seeing.

    For that, you need the --rebase-merges option