Uma U
Uma U

Reputation: 51

git rebase with merge conflicts

       B
       |
       C - E -F my branch
       |
       D

    develop
    branch

my branch has two commits and merge conflicts, what the steps I should follow to rebase my branch and resolve conflicts.

Upvotes: 1

Views: 2267

Answers (2)

Asif Kamran Malick
Asif Kamran Malick

Reputation: 3171

Since you are trying to rebase my branch on develop branch and your my branch has two commits (E and F) that are not in your develop branch, so in order to completely rebase my branch on develop branch git will try to replay the commits that are in my branch but not in develop branch (i.e. E and F) if no merge conflicts are there.

But since in your case git is seeing merge conflicts while trying to rebase, so you will have to resolve the conflicts twice(once for both E and F).

Basically if you are using git bash then you should be able to see something like my branch | REBASE 1/2 in the place of branch name, which means git is trying to replay the first conflicting commit E and asking you to resolve the conflicts by deleting the conflict markers in your files appropriately.

Once you are done with resolving this first conflict as part of REBASE 1/2, you then need to stage your changes via git add and continue to resolving the next conflict by executing git rebase --continue.

You should now see something like my branch | REBASE 2/2 which means you now have to resolve the second conflicting commit F as part of REBASE 2/2. Resolve the conflicts in your files again, perform git add and then git rebase --continue.

You should a message similar to Successfully rebased and updated refs/head/my branch.

This means you have successfully rebased your my branch on top of develop branch.

Upvotes: 1

Joyescat
Joyescat

Reputation: 526

You should do the following:

Start by rebasing your branch

git rebase develop

Then resolve the conflicts and add the file with conflicts

git add [fileWithConflictResolved]

Then git rebase continue to rebase the next commit

git rebase --continue

Repeat until the rebase is done

Upvotes: 1

Related Questions