Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Source control in XCode is a nightmare - can anyone offer advice?

Using Git with Xcode (4.3) is a real nightmare.

Here's a scenario...

I want to add a new feature, so I create a new topic branch.

I add my new feature and I'm ready to commit, rebase and merge...

I commit my changes - fine.

I jump back to master to pull changes (in case someone else has updated the code). Suddenly I get:

error: Your local changes to the following files would be overwritten by checkout:
myProject/project.xcworkspace/xcuserdata/Bodacious.xcuserdatad/UserInterfaceState.xcuserstate

huh? I just committed.

Xcode likes to change my project.xcworkspace files every other second which makes it almost impossible to make clean, atomic commits.

What's more, if I do commit the changes in project.xcworkspace and quickly jump back to another branch (in order to merge into Master for example) then Xcode will complain that the files have changed and probably crash too.

From what I gather, I can't add these files to my .gitignore either.

Do I have to accept that a concise and orderly git strategy is not possible with Xcode, close Xcode before doing any Git management, or is there another option available?

like image 263
bodacious Avatar asked Mar 08 '12 09:03

bodacious


2 Answers

I just add those files to my .gitignore file. There is no need to share them with other developers.

So I have:

*.xcworkspace

In .gitignore

Note that the stackoverflow question you linked to says to not exclude project.pbxproj, but it doesn't say not to exclude *.xcworkspace.

However, I'm not using the workspace feature at this time. If you do use the workspace feature you may want to include those files, but ignore the xcuserdata files.

like image 54
ThomasW Avatar answered Oct 20 '22 23:10

ThomasW


The question you linked was only referring to the xcodeproject/project.pbxproj file. You should be able to safely .gitignore the other files.

like image 27
Amber Avatar answered Oct 20 '22 22:10

Amber