XCode中连接使用GitHub

之前有写了两篇在windows下使用Visual Studio连接GitHub的文章,有需求的可以去看一下。windows中使用Git工具连接GitHub(配置篇) 和 在Visual Studio中使用GitHub(使用篇)

本文是讲在Mac OS中使用XCode连接GitHub。

软件版本:

Mac OS 10.7.4

XCode 4.3.2

不需要另行安装任何软件,XCode的默认源码管理软件就是Git。所以我们要做的只是配置而已。

红色为输入命令 蓝色为自行输入的参数 绿色为注释 色为您系统参数

一、为您的SSH生成密钥

jomatoMac-mini:~ sorex1984ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/sorex1984/.ssh/id_rsa): abcde[文件名]
Enter passphrase (empty for no passphrase): [密码必须大于4位]
Enter same passphrase again: [再次输入密码]
Your identification has been saved in abcde.
Your public key has been saved in abcde.pub.
The key fingerprint is:
ea:74:df:7d:29:de:c9:37:80:49:be:d9:5c:9e:03:94 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|              .  |
|           . E   |
|        S o +    |
|       .   + o . |
|      o .   = = o|
|     o . . + =o*+|
|      .   . o.o=+|
+-----------------+

在/Users/sorex1984/文件夹下我们会看到有abcdeabcde.pub两个文件

二、在GitHub网站上的SSH Key中加入abcde.pub的内容

这里就不详细描述了,不知道怎么加的可以去看windows中使用Git工具连接GitHub(配置篇) 

三、添加SSH到管理器并测试连接

jomatoMac-mini:~ sorex1984$ ssh-add ~/abcde

jomatoMac-mini:~ sorex1984$ ssh -T [email protected]

The authenticity of host 'github.com (207.97.227.239)' can't be established.RSA key fingerprint is ea:74:df:7d:29:de:c9:37:80:49:be:d9:5c:9e:03:94.Are you sure you want to continue connecting (yes/no)?

jomatoMac-mini:~ sorex1984yes

Hi username! You've successfully authenticated, but GitHub does not provide shell access.

四、关联项目

cd 项目文件夹

git remote add origin [email protected]:sorex/iPhoneStudy.git[项目地址]

git pull -u origin master[从网址拉取项目]

git push -u origin master[向网站提交项目]

五、XCode中提交项目

提交到本地:选择要 更新的文件  右键 –> Source Control –> Commit Selected Files [填写注释]

提交到GitHub:File菜单–> Source Control–> Push… –> 选择Remote[一般选择origin/master]

从GitHub获取:File菜单–> Source Control–> Pull… –> 选择Remote[一般选择origin/master]

 

设置个人信息

$ git config --global user.name "sorex"

$ git config --global user.email "[email protected]"

 

到此全部完毕您可以使用GitHub来同步或者发布您的代码了。

 

注:每次重启MAC OS后都需要重新添加key文件

ssh-add ~/abcde

ssh -T [email protected]

发布了88 篇原创文章 · 获赞 11 · 访问量 19万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章