解壓源碼包node
tar xjvf git-1.8.3.tar.bz2
編譯git
cd git-1.8.3 ./configure --prefix=/usr/local make
安裝sql
sudo make install
請參見老左的博客Xcode鏈接git@osc中第一步至第四步。bash
打開命令行工具,執行命令:dom
cd gitOSChina/JBCalendar/ 進入項目的目錄
git init 初始化本地庫(僅第一次時須要)
git remote add origin git@git.oschina.net:JustBen/jbcalendar.git 添加遠程版本庫的別名 git add . 添加全部文件到版本庫 git commit -a -m "commit JBCalendar" 添加全部修改該版本庫 git pull origin master 從遠程庫獲取併合併到本地庫 git push origin master 將修改推送到遠程庫
相似於建立項目時的操做,打開命令行工具,執行命令ssh
cd gitOSChina/JBCalendar/ 進入項目的目錄
git add . 添加全部文件到版本庫
git commit -a -m "commit JBCalendar" 添加全部修改該版本庫 git pull origin master 從遠程庫獲取併合併到本地庫 git push origin master 將修改推送到遠程庫
1. 錯誤:ide
git pull origin master
ssh: Could not resolve hostname git.oschina.net:JustBen: nodename nor servname provided, or not known fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
解決方法:工具
從新設置SSH
cd cd ~/.ssh/ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/Users/yongbin/.ssh/id_rsa): /Users/yongbin/.ssh/id_rsa already exists. Overwrite (y/n)? y Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /Users/yongbin/.ssh/id_rsa. Your public key has been saved in /Users/yongbin/.ssh/id_rsa.pub. The key fingerprint is: f8:87:a4:25:37:7c:bf:64:b1:4f:d5:e1:27:74:18:9e yongbin@YongbinZhang.local The key's randomart image is: +--[ RSA 2048]----+ | . | | . + | | E..| | o ...o| | o S . . ..+| | B + . o o.| | . o . = . | | . o + | | . . | +-----------------+ cat id_rsa.pub | pbcopy 在git.oschina.net中添加一個SSH,直接複製到裏面便可 cd ~/OSChina/JBCalendar/ 進入工程目錄 git add . git commit -a -m "xxxxxxxxxxxxxx" git pull origin master git push origin master
Xcode 已經集成了git,創建新項目時鉤選使用git,而後按照下面步驟讓Xcode和git@osc 創建鏈接。 ui
第一步:成生SSH密鑰google
打開終端命令工具,輸入命令:ssh-keygen -t rsa -C "diaosi@gmail.com"
注意ssh-keygen沒有空格。屏幕輸出:
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/diaosi/.ssh/id_rsa):diaosi
在上方輸入生成的密鑰文件名,如diaosi,屏幕輸出:
Enter passphrase (empty for no passphrase): 輸入密碼
Enter same passphrase again: 確認密碼
Your identification has been saved in diaosi.
Your public key has been saved in diaosi.pub.
The key fingerprint is:
25:fd:01:00:89:98:49:bf:2e:ac:32:2e:d2:5d:bf:98 diaosi@gmail.com
The key's randomart image is:
+--[ RSA 2048]----+
| ..+ ..o... |
| +.. . . . |
| . . o . |
| . o . . |
| . S . |
| . . . |
| .o... . |
|=.... o. |
|*o E .. |
+-----------------+
屏幕提示生成密鑰文件成功,保存在/Users/diaosi文件夾下。
第二步:把diaosi.pub中的內容加入git@osc 的SSH密鑰中
第三步:添加SSH並鏈接
輸入命令:ssh-add ~/diaosi
~/diaosi 是剛剛生成的密鑰文件路徑,屏幕輸出:
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 , 老左!
第四步:設置我的信息
輸入命令:
git config –global user.name 「diaosi」
git config –global user.email diaosi@gmail.com
第五步:設置項目
獲取git@osc 上的項目路徑。
輸入命令:cd 項目文件夾
輸入命令:git remote add origin git@git.oschina.net:heqings/fitness.git
輸入命令:git pull -u origin master //從git@osc 上拉取項目
輸入命令:git push -u origin master //提交項目
第六步:Xcode集成
在Xcode中,提交代碼到git@osc 前需提交到本地git,不然Xcode會提示你。
在項目或文件上選擇文件提交到本地,這裏須要注意的是,工程用戶數據不要提交到git,因它實時在變化,本地和遠程都不要提交,不然Push時提示有文件未提交。
以上文件不要提交。
把項目提交到本地:
File->Source Control->Commit
把項目提交到git@osc :
File->Source Control->Push
點擊Push按鈕便可。