views:

12637

answers:

8

Which files should I include in .gitignore when using Git in conjunction with Xcode?

+34  A: 

Based on this guide for Mercurial my .gitignore includes:

.DS_Store
*.swp
*~.nib

build/

*.pbxuser
*.perspective
*.perspectivev3

I've also chosen to include:

*.mode1v3
*.mode2v3

which, according to this Apple mailing list post, are "user-specific project settings".

Hagelin
I don't particularly like the *.pbxuser/*.perspective/*.perspectivev3 patterns. I much prefer the following*.xcodeproj/*!*.xcodeproj/project.pbxprojThat ignores everything inside a *.xcodeproj except the project.pbxproj.
Kevin Ballard
I do not ignore *.pbxuser, *.perspective and *.perspectivev3 because I like to keep those settings back when I clone my repository.
lajos
Use build/ to exclude only directories named build in case you might have a script or something named build that you don't want to ignore.
nicerobot
I like to leave in build/Release-iphoneos so I have a copy of every released device app I seed out to people. Patterns to add would be build/Debug-* and build/*-iphonesimulator .
Ryan McCuaig
I'm not sure if I'd keep this in my repository. Perhaps a better solution would be to keep your build folder outside of your project in some central location (e.g. /builds/projectname/**) and keep the /builds directory backed up with something like GetDropbox?
Luke Redpath
Also you might want to add that you can make a "global" gitignore file like this:git config --global core.excludesfile ~/.gitignore
Jess Bowers
I agree with Luke regarding his hesitation to keep the build directory version controlled in the same repository. In any case, if you often integrate external libraries and projects into your xcode projects, you should configure your build directory to be common anyway. I typically keep mine in /Users/Shared/<username>/Products
Harkonian
+4  A: 

Mine is a .bzrignore, but same idea :)

.DS_Store
*.mode1v3
*.pbxuser
*.perspectivev3
*.tm_build_errors

the tm_build_errors is for when I use TextMate to build my project. Not quite as comprehensive as Hagelin but I thought it was worth posting for the tm_build_errors line.

Dave Verwer
+4  A: 

Regarding the 'build' directory exclusion -

If you place your build files in a different directory from your source, as I do, you don't have the folder in the tree to worry about.

This also makes life simpler for sharing your code, preventing bloated backups, and even when you have dependencies to other Xcode projects (while require the builds to be in the same directory as each other)

Abizern
I do have the build folder outside of the project folder, but when other users build the project, it by default is recreated in the project- so I found that adding it to the ignore file is a better solution, otherwise it gets readded in their commits.
lajos
+4  A: 

I included these suggestions in a Gist I created on Github: http://gist.github.com/137348

Feel free to fork it, and make it better.

program247365
+1  A: 

make them Global and not at the directory level so your not pushing them to others..

Steve M
+4  A: 

Heres a script I made to auto create your .gitignore and .gitattributes files using Xcode... I hacked it together with a few other people's stuff. Have fun!

http://github.com/tbarbe/Xcode-Git-User-Script

No warranties... I suck at most of this - so use at your own peril

tbarbe
+1  A: 

For Xcode 4 I also add:

YourProjectName.xcodeproj/xcuserdata/*
YourProjectName.xcodeproj/project.xcworkspace/xcuserdata/*
Vladimir Mitrovic