工做環境:Ubuntu9.10.github
A、Git安裝
一、申請GitHub賬戶 xxx ,建立名爲new-project的新Repository
二、安裝Git客戶端(Linux)
#sudo apt-get install git git-core
果你已經安裝好git那麼經過下面命令來更新版本庫。git clone git://git.kernel.org/pub/scm/git/git.git
三、 生成密鑰對,這樣項目能夠push到 GitHub上
#ssh-keygen -t rsa -C "xxx@gmail.com"
四、將.ssh/id_rsa.pub拷貝到GitHub網站
五、修改~/etc/.ssh/ssh_config.
PasswordAuthentication no 去掉#並把 yes改成NO
HostbasedAuthentication no 去掉#
IdentityFile ~/.ssh/identity 去掉#
IdentityFile ~/.ssh/id_rsa 去掉#
IdentityFile ~/.ssh/id_dsa 去掉#
Port 22 去掉#
Protocol 2,1 去掉#
新增:
Host github.com
user git
Hostname github.com
PreferredAuthentications publickey
IdentityFile ~/.shh/id_rsa.pub 添加這個很是重要。
shell執行:ssh-add id_rsa,添加密鑰。
六、執行 ssh git@github.com。或者 ssh -v git@github.com 可查看相應的連接debug的信息。
連接成功後:能夠見到:Hi fuhao715! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Connection to github.com closed.
Transferred: sent 2544, received 2888 bytes, in 1.2 seconds
Bytes per second: sent 2065.4, received 2344.6
debug1: Exit status 1
七、Config用戶名以及郵箱: git config --global user.name "Your Name"
git config --global user.email fuhao-715@163.com
下一步:
mkdir GoProject
cd GoProject
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin git@github.com:fuhao715/GoProject.git
git push origin master
# vi README // 註解 新文件 直接vi保存後,須要git add文件,而後加入 git commit -m 再 git push origin master
更新至遠程
# git push origin master