Using GitHub and Xcode

in a few easy steps you can easily set up Xcode 4’s Git source control with your GitHub repository with an existing project that had no automatic source control before.

  • Create a repository on GitHub
  • Create a new project on Xcode4 and don’t forget to check the checkbox to enable Git source control.

If the project is already created without git source control then follow these 4 instructions in the terminal:

  • Use the cd command to switch to your project folder, making it the current working directory.
  • Enter git init to create an empty repository.
  • Enter git add . to copy your project files into the repository.
  • Enter git commit - m "Initial commit" to commit all the files.

Now your projects are set up and under git version control you can commit from within Xcode

  • From Xcode, commit whenever you want.
  • Using Terminal on you Mac, go to the folder where you created your Xcode project and then type git remote add origin git@github.com:$USERNAME/$REPO.git
    (of course, replace $USERNAME/$REPO with your own)
    git push -u origin master
  • You should now see your project on GitHub. Now you can work in Xcode and commit whenever you want. To push your new commit to GitHub simply type in the Terminal git push

or select push from within Xcode

^