####請先註冊http://git.oschina.net。 ##環境準備:node
###源碼安裝過程:git
解壓源碼包dom
tar xjvf git-1.8.3.tar.bz2
編譯ssh
cd git-1.8.3 ./configure --prefix=/usr/local make
安裝ide
sudo make install
##配置Git並鏈接到git@git.oschina.net 請參見老左的博客Xcode鏈接git@osc中第一步至第四步。工具
##將工程同步到git@git.oschina.netgoogle
在你的git.oschina.net下「建立項目」。.net
在你的電腦上,爲了之後管理方便,應該爲OSChina上的項目創建一個文件夾統一管理,例如gitOSChina。在次級目錄下存放每個項目。命令行
打開命令行工具,執行命令:code
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 將修改推送到遠程庫
至此,新建工程完成了。
##更新工程
相似於建立項目時的操做,打開命令行工具,執行命令
cd gitOSChina/JBCalendar/ 進入項目的目錄 git add . 添加全部文件到版本庫 git commit -a -m "commit JBCalendar" 添加全部修改該版本庫 git pull origin master 從遠程庫獲取併合併到本地庫 git push origin master 將修改推送到遠程庫
至此,更新完畢。
##錯誤小結
錯誤:
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