Reputation: 6695
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?
Upvotes: 10
Views: 6022
Reputation: 17307
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.
Upvotes: 12
Reputation: 887
Here's what worked for me on Xcode 5.1:
Note: if you wait too long or do anything in Xcode before checking out the new branch, you might have to discard changes again
Upvotes: 0
Reputation: 16921
If you can't push your commit just because UserInterfaceState.xcuserstate
has been modified, here's a quick fix:
f01a2147218d by username
)git reset --hard f01a2147218d
Upvotes: 0
Reputation: 526473
The question you linked was only referring to the xcodeproject/project.pbxproj
file. You should be able to safely .gitignore
the other files.
Upvotes: 2