11

I was looking for a way to put my existing project under source control, and I looked at this question, but it looks like that solution only worked with Xcode 4.0 because I can't find a way to do what is advised. I also looked at this question, but that solution doesn't work either because my project isn't currently under source control. How can I get my existing project under source control?

Edit

I want it to be a git repository, not subversion.

Community
  • 1
  • 1
Carter Pape
  • 1,009
  • 1
  • 17
  • 40

3 Answers3

19

you can do it in terminal using:

cd /to/app/folder

git init
git add .
git commit -am 'a descriptor of your first commit'

This should then be picked up in Xcode, you may need to close and re-open

Hope it helps

geminiCoder
  • 2,918
  • 2
  • 29
  • 50
  • 1
    It be prudent to put the **UserInterfaceState.xcuserstate** file in `.gitignore` before doing the `git init` since it changes constantly but does not have anything to do with your code? This can be done by: `find . | grep UserInterface | sed 's:^./::' >>.gitignore` from within the app folder. – LavaSlider Oct 20 '12 at 15:14
  • This is an old post, and I assume most of you already know how to do this, but I just wanted to point out that Apple now has a document that explains perfectly the process of creating a _git_ or _subversion_ repository for a project: [link](https://developer.apple.com/library/ios/DOCUMENTATION/ToolsLanguages/Conceptual/Xcode_User_Guide/085-Save_and_Revert_Changes_to_Projects/manage_project_changes.html#//apple_ref/doc/uid/TP40010215-CH7-SW28). Hope this helps you. – RoberRM Sep 02 '13 at 01:05
  • You are right, @JoãoAbrantes, but I can't edit that link so I'll add a new one [here](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/xcode_guide-continuous_integration/PublishYourCodetoaSourceRepository/PublishYourCodetoaSourceRepository.html). Just scroll down to the bottom of that page, where it says "_Use Git to Manage an Unmanaged Workspace Directory on a Development Mac_". – RoberRM May 14 '14 at 22:55
  • Old post, but answer is still unique and relevant. Link has moved [here](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/xcode_guide-continuous_integration/PublishYourCodetoaSourceRepository.html) – Sean O'Bannon Sep 13 '16 at 22:10
1

If you want to get existing project by xcode (not command line), you can follow this:

  1. Open "Welcome to XCode" window (below menu Window, or press Shift-Cmd-1)
  2. Select "Connect to a repository"
  3. Paste your git URL, and Next.

You can read more in http://www.mindthe.net/devices/2011/04/28/12-steps-to-using-github-with-xcode-4/

KimKha
  • 4,370
  • 1
  • 37
  • 45
0

Here're the steps that can achieve this, but requires cloning your existing project to a new one:

1, (Assume your project is not already under local source control) Create a new project under LOCAL source control (Please note that adding remote source control at this stage may not be successful)

2, Make this new project a clone of your old project - drag files, add frameworks, etc.

3, In menu "Source Control" -> -> "Configure " In the new window, click on "Remotes" -> "+" -> "Add Remote"

4, Name: anything (you can use "BitBucket")

Address: https://accountname@bitbucket.org/accountname/reponame.git

5, "Source Control" -> "Commit"

6, Select "push to remote" at the left bottom corner

7, Click "Commit"

8, Check on BitBucket website to see if it's actually pushed to it

Ascendant
  • 2,430
  • 3
  • 26
  • 34