git添加远程库的时候出现的错误总结

1.GIT报错:connect to host github.com port 22: Connection timed out

错误.png

刚开始以为是密钥错了,尝试把.ssh文件重新生成替换了无数遍,还是不行。

后来通过
1.在.ssh文件夹下新建一个config文件,并写入如下代码:

Host github.com
User "xxx@qq.com"       //你的账户邮箱
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa 
Port 443

2.或者在git的安装路径的ssh文件中添加1中代码(第一种方法不行就用第二种方法)
错误.png
修改示例如下图:
错误.png

然后再执行命令:

$ ssh -T git@github.com              	//只用敲这一行
Hi Anbrosex! You've successfully authenticated, but GitHub does not provide shell access.

问题解决。



2.GIT报错: Repository not found.

报错代码:


$ git push -u origin master
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解决方案:

1.git remote set-url命令修改remote URL

2.git remote set-url传递两个参数

remote name。例如,origin或者upstream

new remote url。例如,git@github.com:USERNAME/OTHERREPOSITORY.git


例如先执行代码:

git remote set-url origin git@github.com:xxxxxx/xxxxxx.git

再执行代码:

$ git remote -v                 //只用敲这一行
origin  git@github.com:Anbrosex/image.git (fetch)
origin  git@github.com:Anbrosex/image.git (push)

问题解决。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值