Xcode and Source Code Management

Adding an existing project to git repository for the purpose of source code management is very simple. Here is a brief tutorial on the subject.

First of all, we will need to navigate to our project’s root directory using terminal. For the sake of this tutorial, my project was saved on my desktop and is called SourceControl.

Regardless of where your project was saved on your Mac, you’ll have to follow the same principle and navigate to your project by replacing “~/Desktop/SourceControl” with the path of your project.

Open terminal and execute the following command (my case):

Before we create a git repository, let’s exclude a file responsible for the state of the Xcode user interface. Execute the following command:

The file we are interested in is the one ending in:

Copy the full file path without the “./” in the beginning and then type the following in terminal:

Verify the line was added:

The output should be the line you just added.

If everything went smooth, now is the time to create the repository. To do that, execute the following:

Then add all files:

And commit:

You are done! As you can see, this process is very simple. Xcode offers the option to “Create local git repository…” upon creation of the project. If you missed it (assuming that’s why you are reading this tutorial), you can always add it manually with a few simple steps.

Xcode and Source Code Management

Leave a Reply

Your email address will not be published. Required fields are marked *