上传项目到GitHub时遇到的问题

出错问题分析

  1. 输入ssh -T git@github.com
    出现错误提示:Permission denied(publickey).因为新生产的key不能加入ssh就会导致连接不上GitHub.
    解决方法如下:
    1.输入 ssh -agent,再输入ssh -add ~/.ssh/id_key。
    2.如果输入ssh -add ~/.ssh/id_key 命令后出现报错Could not open a connection to your authentication agent.解决方法是key用Git Gui的ssh工具生成,这样生成的时候key就直接保存在ssh中了,不需要再ssh-add命令加入了,其它的user,token等配置都用命令行来做。
    3.最好检查一下在你复制id_rsa.pub文件的内容时有没有产生多余的空格或空行,有些编辑器会帮你添加这些的。
  2. 输入git remote add origin git@github.com:account/demo.git
    提示错误信息: fatal: remote origin already exists.
    解决方法如下:
    1.输入 git remote rm origin
    2.再输入 git remote add origin git@github.com:account(GitHub账号)/demo(项目名).git
    3.如果输入git remote rm origin 还是报错的话,
     error: Could not remove config section 'remote.origin'. 
     我们需要修改gitconfig文件的内容,找到你的github的安装路径,
     找到一个名为gitconfig的文件,打开它把里面的[remote "origin"]那一行删掉就好了。
  3. 输入git push origin master
    提示错误信息: error:failed to push som refs to .......
    解决方法如下:
    1.先输入git pull origin master  // 先把远程服务器GitHub上面的文件拉下来
    2.再输入git push origin master
    3.如果出现报错 fatal: Couldn't find remote ref master
      或者fatal: 'origin' does not appear to be a git repository
      以及fatal: Could not read from remote repository,
      则需要重新输入$ git remote add origingit@github.com:account(GitHub账号)/demo(项目名).git
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值