[原创]使用Github代码托管

[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]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值