UPDATE: Apparently just initializing an empty repository in the project directory is enough; Xcode autodetects it for you. It be nice if something to that effect was in the documentation. Thanks to Jason for that (details here). Open the project directory in a terminal and type the following:
git init git add . git commit -m "Initial commit"
I got Xcode 4 - pretty impressive. I've been waiting to get this stable release since I was at the demos at WWDC last Summer. I was particularly excited about the new Git integration.
New Xcode projects will let you keep local git source control. Using an existing project with this local source control is ... difficult. I tried for a while before almost giving up. Documentation around the "Add Working Copy" is almost non-existent. This is how you do it.

- Move your existing project folder to your desktop.
- Make a new, empty project in Xcode with the same name as your project. Make sure the box for using a .git repo is selected.
- Close Xcode.
- Copy all files from the project folder on your desktop to the new project folder Xcode created.
- Double-click the project file.
- You'll now need to add all the files to the source control since (they'll all have question marks beside them, shown right).
I tried adding initializing an empty git repo and importing into Xcode with no luck. If anyone has a better solution, please let me know!
March 16th, 2011 at 2:05 pm
1. Close the project (possibly xcode, cannot confirm)
2. Open terminal
3. Navigate to project directory
4. $ git init
5. $ git commit -a -m "Initial commit" (Possibly not necessary)
6. Open project in Xcode and enjoy git goodness
March 16th, 2011 at 2:14 pm
But how do you get the git repo into Xcode?
March 16th, 2011 at 2:42 pm
Xcode picks it up automatically. Jason says that he doesn't (usually) even need to reopen the project.
March 17th, 2011 at 8:32 am
Oh, cool! Wish that was stated in the docs
March 20th, 2011 at 3:04 am
If you use the command line version that Paddy suggests, you miss out on all of the baked-in .gitignore stuff that Xcode does for a new project, don't you?
March 20th, 2011 at 8:15 am
Jason Brennan has also recommended a good .gitignore file available here that works well. You probably lose the default one set up by Xcode; you could create an empty project and copy their settings over to a global file.
April 20th, 2011 at 2:03 am
Adding existing project to repository
Basicly:
cd /Users/myUserName/Projects/Project-folder
git init
git add .
git commit -m "Initial commit"
April 23rd, 2011 at 12:18 pm
This probably should have read:
I think what is also needed is:
$ git init
$ git commit -a -m "init commit"
$ git add .
$ git commit -a -m "initial add"
Open xcode
July 30th, 2011 at 6:55 am
This is a very helpful post, thank you.
If you're switching from an SVN repository (which I was), the trick is to go into your project folder and delete or rename the .svn directory. For me it seemed that Xcode would find the .svn folder first (or preferred it, even though the backing repository was decommissioned), but once it was gone Xcode would happily start using the git repository.
July 30th, 2011 at 10:22 am
Great tip! I'd always encourage someone to switch to git from SVN
September 1st, 2011 at 9:54 pm
[...] From “How to Create Git Repos for Existing Xcode Projects“: [...]
September 11th, 2011 at 9:49 pm
You also must delete the .svn directories from all of the subdirectories in the project, including the application bundles like (.xcodeproj, .xcdatamodelId, etc.). To track these down you can run this in your project directory: find . | grep .svn
November 2nd, 2011 at 8:48 pm
My favorite way to purge svn ~
find . -type d -name svn -exec rm -rf \{\} \;
November 2nd, 2011 at 8:49 pm
er, make that -name .svn ~
find . -type d -name .svn -exec rm -rf \{\} \;
November 10th, 2011 at 1:02 am
This at least allows me to commit manually through the terminal, but I can't seem to use the commit function in xcode Source Control > Commit
I get:
The operation could not be performed because the file is not under version control.