How do I add Source Control to an existing project - macos

How do I add Source Control to an existing project?
On some of my projects (originally created in Xcode3) I added Source control in Xcode4. I recollect there was an option to do this.
I now want to do similar for some old projects, but can find no way to do so.
I have searched and the only "solutions" I can find is to create a new project, and copy the original source files.
Unfortunately the way Xcode5 structures a new project is quite different, so this is not straightforward.
Is there a way to do this in Xcode5? I could probably do this in git, or even go back to Lion, but I am sure I am not the only person who wants to resurrect an old project.

Xcode doesn't have an option to create repositories for existing projects. You'll have to create a git repository from the command line. Launch the Terminal application, navigate to your project's directory, and run the git init command to create a git repository for your project.
If Xcode doesn't automatically recognize the repository you just created, open Xcode's Accounts preferences and add your repository from there.

Related

Creating an Xcode project from existing .C file on GitLAB [duplicate]

I am working with an existing GitHub repository and I want to create a new Xcode project from it. How can this be done?
I have previously used Xcode just as a python script editor and never created a project, but I would like to do so in this case so that I can have a special indentation style just for the files in this project (this is Python, so no interest in build targets etc, just want to edit and use git).
I am using Xcode 6.0.1 on Mavericks.
IanAuld's answer sent me in the right direction and I figured out what I was doing wrong. I had been assuming that the Xcode project should be inside the directory with the git project, but that was causing problems because then git tries to track the Xcode project.
Here's what I am now doing, which seems to work:
Create a new Xcode project somewhere that is not managed by git. Make sure that "Create Git repository on ..." is not checked.
Clone the github project to a directory that does not include the Xcode project.
In Xcode, File | Add Files to "ProjectName"..., and select the folder with the git project.
Now, if I edit any of those files in the context of the project, it uses the indentation style I set for the project (though if I edit the file on its own it uses my global indentation style), and I can control git through the Source Control menu.
Problem solved.

How to create a new Xcode Project in folder under version control

I have created a new repository in Github, set up the readme.md/.gitignore etc and cloned it to my Mac at user/project.
If when creating the project in Xcode I select user/project as the folder the project is created in user/project/project.
If when creating the project in Xcode I select user as the folder the project is created in user/project, however the folder has been overwritten, losing the link to Github and existing files. I am also unable to clone the git repository in to this new folder.
Is it possible to create a new Xcode project in a folder under version control?
Not really in a convenient way. Generally the easiest way to get what you want is to create the project outside of git (without creating a new repo), and then just move everything into the git directories. (That said, 90% of time I forget to do that and just make inside the git directory and then rearrange things.)

How to add existing Xcode project to git version control in Xcode?

It's clear how to add an existing project to GitHub outside of Xcode, there are a number of tutorial: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
There are also a number of tutorial of how to create a new project in Xcode under version control.
However, there are no tutorial on how to do both: add an existing project with the controls within Xcode. Is this even possible? Or since I already started the project, I'll have to do it all via command line?
Since you didn't ask Xcode for a local git repository inside this project folder when you created the project, you will have to create one via the command line.
After that, you can use Xcode's internal GUI to give git commands in your project - if that's the kind of thing you really want to do (personally I abhor Xcode's git interface).

How to add Git Functionality to an Xcode Project

I have an Xcode Project which I created without support for source control. Is there a way for me to implement it now? Thanks.
Yes, if you create a Git repository in your project directory (using the usual Git tools), then Xcode will see it and offer source control features. You may need to close and open the project first.

XCode 4.3 and SVN

I'm new to iOS developing, I haven't used earlier versions of XCode.
Yet I have stored my project on my local hd. Now I want to use some online subversion service.
I cannot seem to find the appropriate options in XCode. The hints that I googled all refer to a menu called SCM which I don't seem to have.
I created a new and empty repository online (webbased) and tried to configure XCode to use it by selecting the "Connect to a repository" menu when xcode starts. After some tweeking in the command line this "connect to a repository" succeeded but afterwards XCode simply closed itself again.
I tried copying the files that belong to my project to the path that I set up to be used with SVN manually. I opened the project in XCode from that path and after adding another file wanted to commit that change but couldn't find how to do that from within XCode.
Now I found that in XCode / Organizer / Repositories / MyProject is listed but has the type "GIT", which is wrong.
Do I have to change the repository type to SVN instead of GIT? If so, how can I?
When you created the project there was an option to put the project under source control. This option creates a git repository and is checked by default.
To use SVN you have to import your project into the SVN repository. (And you probably don't want it to be under git and svn at the same time, so you'll either delete the .git folder or recreate your project without the scm option selected.) Once the project is imported into your repository then you make sure Xcode knows about the repository and you can check the project out.
But really I'd recommend just using Git. It's a modern version control system with lots of nice features (though to do much of anything out of the ordinary requires using the command line) and there are nice project hosting sites for it like GitHub. I don't think SVN compares very well to git.

Resources