How to resolve git pull conflicts in xcode ui

2019-03-25 16:16发布

问题:

I am using the Xcode repository GUI with the latest version of Xcode instead of the command line. I did an initial pull of the rep without a problem. I made some changes to the local files. At the same time, my other developer made some changes. I committed my changes to the local rep but needed his changes to do a proper build. We only have 1 branch.

I tried to pull and the Xcode UI reports 6 conflicts (which is what I would expect as I need the 6 files to do the proper build).

My question is how to resolve the conflicts? I read online I should be able to use the left and right button at the bottom of screen to let me pick which file version. I went through all of the 6 files and used the proper buttons to choose which changes I wanted.

However the Pull button in the lower right hand corner is disabled and greyed out.

回答1:

Above the file listing of the commit screen are three icons, a directory view, a documents view and the last one which looks like some horizontal lines. When I had a similar issue, I found that clicking on these revealed other files I had not yet resolved.

I resolved those I could although noted that some of these files included some .DS-Store 's which are hidden Apple (Desktop Services Store) files which have been noted elsewhere of causing git issues.

I placed the .DS_Store into .gitignore using the instructions at How can I Remove .DS_Store files from a Git repository?

That fixed it for me.



回答2:

In my case, I just had more conflicts further down that I didn't see. Strangely, since using Xcode 6 this is the first time I've actually had to deal with conflicts -- and I made them! (on a different machine)

At any rate, just scrolling down a bit more revealed that there were more conflicts in the file and once I chose "right" or "left" (or "right then left"/"left then right"), the "Pull" button enabled and I was able to complete my pull...

Whew! Hope this helps!



回答3:

For me, this was a file that had been deleted in the branch but was still present in Master. Once I unchecked that file, I was able to Pull.



回答4:

I had this happen in Xcode 9.4.1, and what I needed to do, after having resolved all the conflicts, was the following:

  • Switch to Source Control view in the left pane above the tree view (the box with a cross symbol in it)
  • Toggle the checkbox next to the top-level project entry from off to on. This would enable the Pull button, but just for a second, not long enough to click it.
  • Toggle the checkbox back to off, and back to on again. Now the Pull button remains enabled.
  • Click Pull.

This feels very much like a bug; I haven't verified yet if the issue persists, and the solution still works, in Xcode 10.



回答5:

Just do "git pull" from the command line, then rebuild to find the conflict markers and fix them manually.