If you have worked on an existing Xcode project for some time and decide that you want to add a Git repository to better track your files, you will want to do the following steps:

  1. Start off by backing up the folder as a general safety precaution
  2. Now would be a good time to add an ignore file. See ignore file section below.
  3. In a terminal, CD to your project directory containing your .xcodeproject file
  4. Run the commands (credit to Mcannon):
    1. git init
    2. git add .
    3. git commit -m “Initial Commit”
  5. Close and restart Xcode if you had it open.
  6. To verify, open your Xcode project and click Source Control from the top menu. You should now see Working Copies with your project name – Master below it.

Ignore File

Your project file has a bunch of user settings such as breakpoint locations that will by default be stored into the repository. This is not necessarily a bad thing however it can be frustrating to have this pile up the list of uncommitted code every time you check in. Also, in a multi-user environment, you’re likely better off avoiding all the user setups. In addition, files such as build files generally shouldn’t be added to Git, among others.

There is a very handy thread over at Stack Overflow where Adam created a template file to use for your ignore file. I recommend using the template file (it works with Xcode 4/5 at the time of this article regardless of its commenting for mostly 4) provided there. This file will reside in your root project directory (containing your .xcodeproject) where we will be making the repository.  It’s file name must be .gitignore


If you have issues with the ignore file appearing to go unnoticed. You may have some files checked in prior having the rules set in place. Check out this post for tips on how to resolve that.

No Comments

There are no comments related to this article.