52

After Xcode has updated to version 8.0 (8A218a), I have a problem pulling changes from git repository from Xcode only when some files are conflicted. We are all working on the same branch.

As long as there are no conflicts, everything works perfectly and I am able to commit, pull and push.

But I figured out that whenever we have a conflict in some of the files, Xcode is not showing conflicts anymore. It just closes the pull popup window without showing the conflict resolver window. No info or anything. I don't see the

Pull successful

message. And I can't push my commit (because changes are not pulled) getting the message:

Make sure all changes have been pulled from the remote repository and try again

I have tried pulling using terminal, but the conflicted file gets messed up with git messages showing mine and other people changes in the same conflicted file along those git messages. And the files that other people were working on are now shown as my own changes/additions.

I also tried updating git to the newest version, which is currently 2.10.0. No luck either.

So I end up deleting my copy and cloning the latest one and reapplying changes that i've made which is very annoying.

Does anyone have a solution for this?

EDIT: Here is what you can do as a workaround using the terminal:

  1. Open terminal and tell the system where Xcode utilities live:

    sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
    
  2. Set "opendiff" as the default mergetool globally:

    git config --global merge.tool opendiff
    
  3. Open Xcode mergetool manually and get rid of the conflict the usual way:

    git mergetool
    
  4. Save changes, commit, push.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Despotovic
  • 1,807
  • 2
  • 20
  • 24
  • 1
    I have same issue with Xcode 8, Xcode is not showing any conflicts and override without my permission. Did you find any solution ? – Anand Suthar Sep 23 '16 at 06:59
  • No, I have not found a solution. Still looking... It seems like a bug in new Xcode. – Despotovic Sep 23 '16 at 08:26
  • Same issue occurs when I'm trying via terminal (command line) why? because of Xcode8 change default git utility to "Apple Git-73" version 2.8.4. ---> When I install Git via brew it shows me version 2.8.1 and when I check Git version in terminal it shows git version 2.8.4 (Apple Git-73) --> Is there any way I can use other git version, If possible then we can use DiffMerge for conflicts resolutions. – Anand Suthar Sep 26 '16 at 06:55
  • I have same issue – Mohamed Helmy Sep 26 '16 at 09:49
  • We have encountered the same problem today. We will try to avoid creating new conflicts... until we find another solution. – Arik Segal Sep 26 '16 at 10:29
  • 1
    The beta version of Xcode 8.1 has the same bug – Marck Gorgon Sep 28 '16 at 20:33
  • Related post on Apple developer forum: https://forums.developer.apple.com/message/185200 – Chris Comeau Oct 03 '16 at 20:04
  • @Chris, this FisherJoe copied my question on on Apple developer forum. But still no solution... – Despotovic Oct 03 '16 at 20:15
  • 1
    Xcodes versioning was never trustworthy. If you want to use a GUI, I can recommend "SourceTree". – shallowThought Oct 18 '16 at 13:11
  • Can we get an example of _I have tried pulling using terminal, but the conflicted file gets messed up with git messages showing mine and other people changes in the same conflicted file along those git messages._ ? Because what you are describing might be the way git handles conflicts. Have you ever tried to fix conflicts via a text editor? (i.e. not via your IDE's help) – Thibault D. Oct 25 '16 at 06:33
  • (Read about my comment here: http://stackoverflow.com/questions/7901864/git-conflict-markers ) – Thibault D. Oct 25 '16 at 06:34
  • Just an fyi, you should not be working on the same branch. That is asking for trouble. Make a branch each and when you need something that the other person created, just pull their branch in yours. – vrwim Dec 06 '16 at 11:58

5 Answers5

2

I use git in Terminal to solve this problem, mergetool is used. Fisrt, I pull some changes, but oops, not up to date:

git fetch origin
git pull origin master

From ssh://gitosis@example.com:22/projectname
 * branch            master     -> FETCH_HEAD
Updating a030c3a..ee25213
error: Entry 'filename.c' not uptodate. Cannot merge.

So get up-to-date and try again, but have a conflict:

git add filename.c
git commit -m "made some wild and crazy changes"
git pull origin master

From ssh://gitosis@example.com:22/projectname
 * branch            master     -> FETCH_HEAD
Auto-merging filename.c
CONFLICT (content): Merge conflict in filename.c
Automatic merge failed; fix conflicts and then commit the result.

So I decide to take a look at the changes:

git mergetool

use mergetool to merge the conflict

changes...no...their changes...
git checkout --ours filename.c
git checkout --theirs filename.c
git add filename.c
git commit -m "using theirs"

And then we try a final time

git pull origin master

From ssh://gitosis@example.com:22/projectname
 * branch            master     -> FETCH_HEAD
Already up-to-date.

answer from:How to resolve merge conflicts in Git?

Community
  • 1
  • 1
Wayne Chen
  • 305
  • 2
  • 15
1

The following sequence of actions resolves this problem:

Exit Xcode

Open Terminal and cd to the project's folder

git checkout -- .

git pull

Look at the output of the pull command. It should announce that there is a conflict in one of the files. Open this file in an external editor (not Xcode). The file should now contain special markers describing the conflict (they were added by GIT) The markers look like this:

<<<<<<< HEAD:file.txt
Hello world
=======
Goodbye
>>>>>>> 77976da35a11db4580b80ae27e8d65caf5208086:file.txt

Delete the markers and resolve the conflict

git add [file name]

git commit -m "conflict in [file name] resolved"

git push

Arik Segal
  • 2,963
  • 2
  • 17
  • 29
1

Please update to Xcode 8.2.1

I had the same problem.But it is resolved once I have updated my Xcode version to 8.2.1.

I have resolved all the conflicts today,which I was facing with Xcode Version 8.1.

Karthick Vadivel
  • 421
  • 5
  • 10
0

update your Xcode to the latest version and make sure your partners have the same one too

Dory Daniel
  • 798
  • 14
  • 21
-1

Happens to me still in Xcode 8.1, using Github.

Doing git fetch in the terminal, and then pulling from Xcode again seems to fix the issue for me.

Marin Bencevic
  • 301
  • 3
  • 6