---
title: "在xcode里面建立github"
author: "fishyych"
date: "2014-09-10T20:47:49Z"
tags: []
categories: ["移动开发"]
slug: "xcode-github"
draft: false
lastmod: "2014-09-10T20:47:49Z"
id: 2115024
url: "https://fishyych.iteye.com/blog/2115024"
---

**GitHub Setup**

1. Create repository on GitHub
2. Get SSH URL such as: [git@github.com](mailto:git@github.com):ACCOUNT/PROJECT.git
3. Generate and add your Public SSH key to your GitHub Account (You can follow [this](http://www.elastichead.me/2013/01/github-and-xcode.html#.Ul9pGWRMVGT) tutorial （https://help.github.com/articles/generating-ssh-keys）, just steps 1. up to 6.; don't do steps 7. and on).

**XCode Setup**

1. Create a new project in XCode (DO NOT select the local git repository/source control option, we will do this manually).
2. Close XCode (important!).

**Local Git Setup**

1. Browse to the project path where the .xcodeproj file is.
2. Execute the following from your command line:
   
   ```
   git init
   git add .
   git commit -m 'Initial commit from local git'
   git remote add origin git@github.com:ACCOUNT/PROJECT.git
   git pull origin master
   (VIM editor opens)
   Hit 'i' to add a comment, for example 'Initial merge to sync local git with remote git'. 
   Hit 'ESC'.
   Hit 'ZZ'.
   (VIM editor closes)
   git push origin master
   ```

Finally, open project on XCode. If everything went OK you'll see Source Control is configured for GitHub use.

If you try it please let me know how it goes.