Creating an Xcode Project to Work with GitHub or Bitbucket

GitHub and Bitbucket are two of the most popular sites for storing git repositories online. In this article you’ll learn how to create an Xcode project and have it hosted on GitHub or Bitbucket.

NOTE

It may sound obvious, but you must first sign up for an account on GitHub or Bitbucket.

Hosting an Xcode project on GitHub or Bitbucket sounds difficult, but it’s really not. Perform the following steps to host a new Xcode project on GitHub or Bitbucket:

Create a new Xcode project by choosing File > New > Project in Xcode.

When choosing a location to save the project, select the Create git repository checkbox to create a local git repository for your project on your Mac.

Login to GitHub or Bitbucket.

Create a new repository.

When you create a new repository, GitHub and Bitbucket provide instructions on how to push an existing repository to your newly created repository. This involves running two git commands: git remote add and git push.

Launch the Terminal application on your Mac.

Navigate to your Xcode project’s directory.

Run the two git commands. You can copy and paste them from GitHub or Bitbucket.

The git remote add command makes your newly created GitHub or Bitbucket repository a remote branch of the local repository on your Mac. The git push command pushes the files under version control from your local repository to the remote repository hosted on GitHub or Bitbucket.

Now you can push changes to GitHub or Bitbucket from Xcode by choosing Source Control > Push.