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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章