工作环境:Ubuntu9.10 github
1、申请GitHub帐户 xxx ,创建名为new-project的新Repository
2、安装Git客户端(Linux)
#sudo apt-get install git git-core
若已经安装好git,那么通过下面命令来更新版本库。
git clone git://git.kernel.org/pub/scm/git/git.git
3、 生成密钥对,这样项目可以push到 GitHub上
#ssh-keygen -t rsa -C "xxx@gmail.com"
4、将.ssh/id_rsa.pub拷贝到GitHub网站
5、修改/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 ~/.ssh/id_rsa.pub 添加这个非常重要。
shell执行:ssh-add id_rsa,添加密钥。
6、执行 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
7、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
摘自http://m.oschina.net/blog/14413
阅读(3554) | 评论(0) | 转发(0) |