Using Xcode with Git

Posted by shane
on Wednesday, July 09

For Xcode and Git to work smoothly with each other, you need to make sure Git treats Xcode project files properly. You do this by configuring Git via .gitignore and .gitattributes. Create these files in your repo’s root folder and add the following lines:

.gitignore

# xcode noise
build/*
*.pbxuser
*.mode1v3

# old skool
.svn

# osx noise
.DS_Store
profile

.gitattributes

*.pbxproj -crlf -diff -merge

The line in .gitattributes treats your Xcode project file as a binary. This prevents Git from trying to fix newlines, show it in diffs, and excludes it from merges. Note that you will still see it shown as a conflict in merges, although the file won’t have changed. Simply commit it and things should be good.

Thanks to Jonathan Wight and Chris Double.

Comments

Leave a response

  1. JamesAugust 21, 2008 @ 07:47 AM

    Hi there,

    Thanks for the post, it was really what I need since I’m using Git with XCode. However, after adding the .gitattributes with the line specified Git started behaving weird. I create a branch, make modifications, and checkout another branch. I see the modifications of the previous branch in the new one! Are you having the same problem?? Please anyone with any knowhow about this all help will be appreciated.

    James

  2. KennonAugust 22, 2008 @ 03:42 AM

    James, did you check in those changes on the other branch first? If you have uncommitted changes, when you checkout a new branch the modifications will come with it (that’s standard git behavior)


shanesbrain.net.sharedcopy.com