[size=medium]Github大家应该听说过,没听说过的话,自己google
一,申请github帐号
很简单,上github.com注册。
二,新建repository,在github上找到AddRepository,新建一个代码库
三,添加本机的ssh-key
在 Edit profile中有一个ssh-key
首先看一下home目录下有没有.ssh/
然后
ssh-keygen -t rsa -C "your_email@youremail.com"
电子邮件是你注册github的电子邮件
apt-get install xclip
xclip -sel clip < ~/.ssh/id_rsa.pub
最后,粘贴到key选项去。
四,提交本地代码
cd 到你要提交的代码目录下面
git init
git remote add origin git@github.com:***.git
git add .
git commit -m 'First commit'
git push origin +master//注意这个+号,强制提交
五,测试一下
git clone git@github.com:****.git
注意:
***.git是你的项目地址
如果出现
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:young001/personal_config.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
fast-forwards' section of 'git push --help' for details.
就是要用git push origin +master这个命令了
如果出现
error: src refspec master does not match any.
error: failed to push some refs to 'ssh://xxxxx.com/project.git'
这个错误,就是要用git add .
参考资料
[url]http://magicode.blog.com/2010/09/28/%E7%94%A8github%E5%81%9A%E4%BB%A3%E7%A0%81%E6%89%98%E7%AE%A1/[/url]
[url]https://help.github.com/articles/generating-ssh-keys[/url]
[url]http://blog.enjoyrails.com/2008/12/31/git%E4%B8%80%E5%88%86%E9%92%9F%E6%95%99%E7%A8%8B/[/url]
[/size]
一,申请github帐号
很简单,上github.com注册。
二,新建repository,在github上找到AddRepository,新建一个代码库
三,添加本机的ssh-key
在 Edit profile中有一个ssh-key
首先看一下home目录下有没有.ssh/
然后
ssh-keygen -t rsa -C "your_email@youremail.com"
电子邮件是你注册github的电子邮件
apt-get install xclip
xclip -sel clip < ~/.ssh/id_rsa.pub
最后,粘贴到key选项去。
四,提交本地代码
cd 到你要提交的代码目录下面
git init
git remote add origin git@github.com:***.git
git add .
git commit -m 'First commit'
git push origin +master//注意这个+号,强制提交
五,测试一下
git clone git@github.com:****.git
注意:
***.git是你的项目地址
如果出现
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:young001/personal_config.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again. See the 'Note about
fast-forwards' section of 'git push --help' for details.
就是要用git push origin +master这个命令了
如果出现
error: src refspec master does not match any.
error: failed to push some refs to 'ssh://xxxxx.com/project.git'
这个错误,就是要用git add .
参考资料
[url]http://magicode.blog.com/2010/09/28/%E7%94%A8github%E5%81%9A%E4%BB%A3%E7%A0%81%E6%89%98%E7%AE%A1/[/url]
[url]https://help.github.com/articles/generating-ssh-keys[/url]
[url]http://blog.enjoyrails.com/2008/12/31/git%E4%B8%80%E5%88%86%E9%92%9F%E6%95%99%E7%A8%8B/[/url]
[/size]