31

I'm working on a project, so I pushed a feature branch to the remote repository(using Atlassian bitbucket) and opened a pull request.

But on one file, the bitbucket diplay a "MOVED" status, in brown and shows a conflict message :

conflict: modified on source, modified in target.

this file is in a conflicted state. You will need to resolve the conflict manually before you can merge this pull request.

So when I typed:

git pull origin my_feature

I get the message

Already up-to-date.

How can I resolve this conflict?

Community
  • 1
  • 1
NI6
  • 2,477
  • 5
  • 17
  • 28
  • The problem is for the `merge` operation of your branch onto `master` (I guess). you should first merge `origin/master` into your branch and solve the conflict (apparently a file you modified was moved in `master` branch). Once solved, commit and push your branch again and reopen your pull request. – Frodon Sep 26 '16 at 13:06
  • I tried, but it also says already up to date – NI6 Sep 26 '16 at 13:08
  • 1
    Did you run `git fetch` ? – Frodon Sep 26 '16 at 13:09
  • Yes, but unfortunately it changed nothing – NI6 Sep 26 '16 at 13:16
  • Can you share the result of "git status" operation for your repository? – Vitalliuss Sep 27 '16 at 16:04

1 Answers1

58

You need to update your local master branch. Do the following steps:

  • git checkout master
  • git pull origin master
  • git checkout << your branch >>
  • git merge master

After you execute the 4th command, you will get merge conflicts. Resolve them and then do:

  • git commit
Lets Code
  • 723
  • 8
  • 15
  • 8
    After working with git a while, I now understood what happened. Git pull doesn't pull commits to the whole repository, just the branch your'e using. To merge with another branch, you have to check out that branch and pull it, too. Then both will be up to date and a merge will work as expected, conflicts and all. Git is a stupid git. – Suncat2000 Sep 26 '18 at 13:15
  • 5
    @Suncat2000 It would be terrible if git pulled every branch on `git pull`. You could end up merging branches you're not yet ready to merge. – AlexJ Sep 09 '19 at 12:12
  • 1
    @AlexJ, So a good practice before making a pull-request(or even before committing & pushing your changes to your branch) would be to 1. checkout the master branch and fetch it(so that you get all the changes ) 2. switch to dev branch and fetch it, not you can see what changes other developer did which you wanna keep. 3. commit/push your changes to remote->dev and 4. git merge master. – Anu Feb 06 '20 at 22:31
  • @Suncar2000 On the contrary, git is exceptionally clever, you just have to be on your toes – Scott Anderson Apr 14 '21 at 07:49