Creating a Git repository for an existing project with Xcode

This tutorial shows how to create a git repository and remote for an existing project with Xcode. This could also be used for new projects, but there are easier ways to do that. If anyone has a more effective way to do this, please comment below.

First, create the folder. Type this command into teminal replacing (username) for your name and (foldername) for the name of the new folder:

sudo -u (username)  mkdir -m 770 (foldername)

After you do that, cd into that folder:

cd (foldername)

Create an empty repository:

sudo -u (username)  git --bare init --shared=group

Now you are done with the command line. That wasn’t so hard, was it? Now, open up Xcode and you should see a window like this:


Click on connect to a repository and you should see a window like this:


Type in the url to your repository and click next. You should see a window like this:


After you type in the name, make sure you make the type git and click clone. It will ask you where to save this. Save it wherever you want.

Now, open your existing project folder and the new folder you just made and transfer the files from the existing project to the new folder. Like this:

Project Files Transfer

Now, open the project from the folder and you should be able to commit the files. You cannot commit the .xcodeproj file and you will get an error if you do. Once you have committed, you can push the files. That’s it! You now have a project set up for a repository. Leave any comments below.