1
       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.

3
  • Where do you have the merge conflict? Merging with the develop branch, or merging with your own upstream? Commented Aug 24, 2021 at 16:23
  • If you have merge conflict, you will probably also have conflict when doing a rebase. Commented Aug 24, 2021 at 16:25
  • merging with develop branch Commented Aug 24, 2021 at 16:26

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.