`
wangzt_2008
  • 浏览: 44357 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

git及github使用

阅读更多

1、生成ssh公钥

ssh-keygen -t rsa -C "your_email@youremail.com"

 

2、添加公钥到git仓库

就是将在用户主目录中.ssh文件夹下的id_rsa.pub文件中内容上传到git仓库

 

对于github仓库,打开github,找到账户里面添加SSH,把idrsa.pub内容复制到key里面

 

3、测试是否生效

这里连接github,使用命令:ssh -T git@github.com

 

4、连接成功后,下载库到本地

git clone git://github.com/{yourname}/{yourRep}.git

 

5、本地修改代码后提交

当前在master上:git push origin master

会出现如下错误:

fatal: remote error:

  You can't push to git://github.com/{yourname}/{yourRep}.git

  Use https://github.com/{yourname}/{yourRep}.git

 

解决方法:

git remote rm origin

git remote add origin git@github.com:{yourname}/{yourRep}.git

 

6.迁移git服务器

 

git commit -m "Change repo." # 先把所有为保存的修改打包为一个commit
git remote remove origin # 删掉原来git源
git remote add origin [YOUR NEW .GIT URL] # 将新源地址写入本地版本库配置文件
git push -u origin master # 提交所有代码
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics