0

First, I am sorry to ask such question because I am sure it is a straightforward issue, still I found no solution an no way to understand what I am doing wrong. Some people asked almost exactly the same question (except the squash part) and the answer was obvious (rebase) but does not work for me.

I create a branch A, multiple commits, then I submit a merge request A->develop, with commit squash on.

While I wait for the MR to be accepted, I want to work on a new issue, from the branch A. So I create a branch B from branch A.

At some point branch A got merged into develop, and all the commit from A squashed into a single commit in develop.

Once my work on B is finished, I create a new MR B -> develop. But I can't because develop has been updated with changes from A. As I already have these changes in my branch B, because I created B from A, it should not be an issue. But it is.

No matter what I do from B:

git merge develop

or:

git rebase develop

I get an endless list of fake conflicts.

I suspect the issue is that the commit logs on my branch B includes all old commits of the branch A, whereas develop includes only one single squashed commit of the branch A. So they are not seen as the same commits and I get conflicts even though there are no actual conflicts. But I have no solution.

Any help would be appreciated. Thanks.

haltux
  • 61
  • 4
  • 1
    `git rebase --interactive` and manually edit out the commits from "A". Or if you still have your local branch "A" with the individual commits `git rebase --onto develop A B`, meaning: rebase all in B, since A onto develop – Martin Mar 17 '22 at 15:45
  • Looks great, I will try it next time. I have to say my knowledge of rebase was way too basic, after your answer I spent some time studying it, things are much clearer now. – haltux Mar 17 '22 at 21:32

1 Answers1

0

Yes, you are trying to rebase all commits develop..A again on top of the merge-commit of develop and A.

Best is to use rebase --onto:

git rebase --onto develop $last_commit_of_A B

Or run without --onto and then execute git rebase --skip for those already-merged commits.

Or use an interactive rebase (git rebase -i develop B) and delete (or change action to "drop") the lines that were already merged as part of A.

knittl
  • 246,190
  • 53
  • 318
  • 364