Conflict on bitbucket remote server but everything is up to date locally
Asked Answered
S

2

35

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?

Sungsungari answered 26/9, 2016 at 12:59 Comment(6)
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.Montmartre
I tried, but it also says already up to dateSungsungari
Did you run git fetch ?Montmartre
Yes, but unfortunately it changed nothingSungsungari
Can you share the result of "git status" operation for your repository?Finkle
I had something similar. My problem was that my main branch was disconnected from origin. After re-establishing the connection I saw the conflict locally as wellPhonoscope
G
62

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
Geopolitics answered 29/6, 2017 at 10:43 Comment(4)
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.Bedard
@Bedard 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.Ramer
@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.Tomkin
@Suncar2000 On the contrary, git is exceptionally clever, you just have to be on your toesAccident
H
0

None of these solution worked for me. In my case the config file had mirror url and I was raising PR against actual origin.

check .git > config > url

Holbrooke answered 25/7 at 12:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.