luckyging3r
luckyging3r

Reputation: 3165

Merge conflict - Git rebase master which is master

So I am still newish with git and have just discovered the rebase option to update a branch with master.

I ran:

git checkout mybranch
git rebase master

Now I have a few merge conflicts. Is this the same as fixing normal merge conflicts? I want to accept masters changes. I get something like

<<<<<<< 6tyuhjhgty54rtfghgftr
=======
    <bunch of code here>
>>>>>>> Updates from Company

Which is which?

Upvotes: 0

Views: 341

Answers (4)

in your master branch you need to use

git pull origin master
git checkout mybranch
git rebase -X ours master

Upvotes: 0

Matthew Hallatt
Matthew Hallatt

Reputation: 1380

When you call git rebase master from your branch, the first thing git is going to do is checkout the master branch.

This means that the changes made on master are --ours and the changes made on mybranch are --theirs.

Alwyn is correct in saying that from there, if you want to, you can call git checkout --theirs/--ours -- path/of/file depending on whether you want the changes from mybranch or master.

Upvotes: 1

Alwyn Schoeman
Alwyn Schoeman

Reputation: 466

If you want to replace your changes with their changes as a whole for a file, then you can do a git checkout --theirs -- path-of-file

In your example above, the code above the ===='s is yours and the code below is the incoming code.

Upvotes: 1

Related Questions