Xcode项目文件git合并冲突

问题描述:

在Xcode中,避免项目文件中Git冲突的最佳方法是什么? (我使用的是手动git,而不是使用git的Xcode接口)

In Xcode, what's the best way to avoid Git conflict in the project file? (I am in manual git, not using Xcode interface for git)

我已经从Github克隆了mapbox-ios-sdk并对其进行了黑客攻击,现在远程主服务器已更改.当我尝试将远程更改拉入本地时,合并后,项目文件中将存在合并冲突. (具体来说,我是指.xcodeproj中的project.pbxproj)

I've cloned mapbox-ios-sdk from Github, hacked it, and now the remote master has changed. When I tried to pull the remote changes into my local, after merging there would be merge conflict in the project file. (Specifically, I mean the project.pbxproj in the .xcodeproj)

我真的不认为应该将项目文件置于忽略状态,因为如果项目文件中有任何新文件,则.pbxproj文件似乎已更改. (或者我只是犯错了,应该忽略此文件?但是显然,开始它并没有在mapbox-ios-sdk中被忽略.人们毕竟需要项目文件.)但是我也运行了在与另一个协作者进行协作项目之前就陷入了这种冲突,这使我无法完全使用Git.

I do not really think project file should be put into the ignore, since if there are any new files the project file, the .pbxproj file seems to be changed. (Or am I just plain wrong and this file should be put to ignore? But obviously it wasn't on ignored in the mapbox-ios-sdk to begin with. People need the project file after all.) But I've also ran into this conflict before in my collaboration project with another collaborator and it's keeping me from using Git altogether.

我应该弄清楚如何手动解决冲突,还是有更好的方法来解决这一问题?

Should I figure out how to manually resolve conflict or is there a better way to deal with this?

.pbxproj在将新文件添加到项目时将更改.如果两个或多个协作者同时添加文件(不会先获取彼此的更改),则会发生冲突.在我的项目中,通过添加新文件之前和之后执行以下步骤来避免这种情况:

.pbxproj will change when you add new files to the project. There will be conflicts if two or more collaborators add files at the same time (without getting one another's changes first). We are avoiding this in my project by following these steps before and after adding new files:

  1. 在添加文件之前,先进行更改,然后再从主服务器上获取最新版本.如果有人添加了文件,则现在拥有最新的.pbxproj
  2. 添加文件.
  3. 立即提交更改并将其推送到主服务器(希望在其他协作者添加另一个文件之前).

这太不可思议了,但是我们不喜欢手动解决.pbxproj冲突.

It's wimpy, but we don't relish manually resolving .pbxproj conflicts.

此外,请参阅以下有关堆栈溢出的问题,并提供出色的答复:如何使用Git正确使用XCode?​​a>

Also, see this Stack Overflow question with excellent responses: How to use Git properly with XCode?