Git的簡單工作流程
想用開源中國上面的git,用Xcode連接git@osc。開始參照了老左的博客,但是后來做到關(guān)聯(lián)Xcode時候,commit時,總是提示密碼錯誤。自己總結(jié)了一下如果關(guān)聯(lián)的方法。
生成SHH秘鑰
打開終端命令工具,輸入命令:ssh-keygen -t rsa -C”bjlidaxx@163.com";
注意ssh-keygen沒有空格。屏幕會輸出:
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/diaosi/.ssh/id_rsa):bjlidaxx
在上方輸入生成額秘鑰文件名,如bjlidaxx,屏幕輸出:
Enter passphrase (empty for no passphrase): 輸入密碼
Enter same passphrase again: 確認密碼
Your identification has been saved in bjlidaxx.
Your public key has been saved in bjlidaxx.pub.
The key fingerprint is:
25:fd:01:00:89:98:49:bf:2e:ac:32:2e:d2:5d:bf:98 bjlidaxx@163.com
The key's randomart image is:
+--[ RSA 2048]----+
| ..+ ..o... |
| +.. . . . |
| . . o . |
| . o . . |
| . S . |
| . . . |
| .o... . |
|=.... o. |
|*o E .. |
+-----------------+
屏幕提示生成密鑰文件成功,保存在/Users/diaosi文件夾下。
把bjlidaxx.pub中的內(nèi)容加入git@osc的SSH秘鑰中
添加SSH并連接
輸入命令:ssh-add ~/bjlidaxx
~/bjlidaxx 是剛剛生成的密鑰文件路徑,屏幕輸出:
Enter passphrase for /Users/diaosi/diaosi:輸入密碼
Identity added: /Users/diaosi /diaosi (/Users/diaosi /diaosi)
輸入命令ssh -T git@git.oschina.net,屏幕輸出:
The authenticity of host 'git.oschina.net (58.215.179.44)' can't be established.
RSA key fingerprint is 14:b8:b8:0b:c2:b2:5e:ae:f2:21:f8:18:4d:3a:be:fc.
Are you sure you want to continue connecting (yes/no)? yes(輸入yes),屏幕輸出:
Warning: Permanently added 'git.oschina.net,58.215.179.44' (RSA) to the list of known hosts.
Welcome to Git@OSC , peant_iOS!
Check out an existing project
利用Xcode的歡迎界面中的Check out an existing project 按鈕來檢出你在git@osc中創(chuàng)建的項目
然后輸入你的git@osc項目地址
選擇你想要存放git@osc項目的路徑,也相當于你這個項目在本地建立了一個存放的庫(我是這么理解的)
然后check out。
如下圖:

建立項目
你想將你的項目提交到git@osc的話,項目一定要保存到GitDemoShow目錄下(也就是檢出(check out)的項目目錄下)
把項目提交到本地:
File->Source Control->Commit
把項目提交到git@osc :
File->Source Control->Push
然后push。