Add local repo for existing Xcode 5 Project

14,103

Solution 1

I would do this from the command line.

  1. Close Xcode.app
  2. Open Terminal.app
  3. $ cd /path/to/project/dir
  4. $ git init .
  5. Create a .gitignore file to ignore some of the Xcode and output files that you don't want tracked (see below).
  6. $ git add .gitignore
  7. $ git add .
  8. $ git commit -a -m Initial.

Sample (but incomplete) .gitignore file:

build/
*/xcuserdata/

And most likely you'll want to add a remote tracking repo, perhaps on github or bitbucket (once a bare repo has been created there):

$ git remote add origin https://bitbucket.org/yourname/yourrepo.git
$ git push -u origin --all
$ git push -u origin --tags

When you open the Xcode project next time it will be ready for Source Code use.

Solution 2

Apple's official solution is here. See "Use Git to Manage an Unmanaged Workspace Directory on a Development Mac"

Share:
14,103
SamoanProgrammer
Author by

SamoanProgrammer

Updated on July 26, 2022

Comments

  • SamoanProgrammer
    SamoanProgrammer almost 2 years

    I've running through a Xcode 5 tutorial and want to make some significant changes, but want to make this Xcode 5 project into a repository.

    I've done some reading and you can add a repository by going to Xcode -> Preferences -> Accounts -> Add Respository -> Enter the repository address:

    So what would I input here for a local repository (on my iMac) I'm wanting to work on?

    Cheers.

  • trojanfoe
    trojanfoe almost 10 years
    @shashwat Yes, and each one is different. 4. it's the current directory. 6 it marks the file as hidden and 7. it's a full stop.
  • user3344977
    user3344977 over 9 years
    Steps 5 and 6 did not work for me. I had to use this instead: $ touch .gitignore
  • Nathan Noble
    Nathan Noble over 9 years
    You will have to do a "git add ." before doing a git commit