git error “Please make sure you have the correct access rights and the repository exists.”

网上很多是创建新的秘钥去替换。

(我的不是,首先找出问题所在)

由于配置了两个秘钥在同个ssh里面,我使用的是图形客户端sourcetree。用另一个连接,非github仓库没问题。那么证明是github的链接不了(github的链接是时常抽风)。

所以我这边的解决方法是:为sourcetree添加代理:在sourcetree的-选项-网络-使用自定义网络:

服务器:http://127.0.0.1
端口:10086(不知道的看下方的本机电脑的设置里面的代理参数)

查看自己开完科学上网工具后的代理参数。用于配置git的代理。
方法:
win10-开始-设置-主页-网络-代理。查看代理地址

下方为手动设置git代理(非图形界面的设置方法)

右键打开:Git Bash

临时设定

手动配置代理

//--global 表示全局,不需要可以不加
git config --global http.proxy http://127.0.0.1:10086
git config --global https.proxy https://127.0.0.1:10086
//或socks5
git config --global http.proxy socks5://127.0.0.1:10086
git config --global https.proxy socks5://127.0.0.1:10086
只对github.com使用代理,其他仓库不走代理
# 只对github.com使用代理,其他仓库不走代理
git config --global http.https://github.com.proxy http://127.0.0.1:10086
git config --global https.https://github.com.proxy https://127.0.0.1:10086
//或socks5同上。修改后面的地址就可以了
git config --global http.https://github.com.proxy socks5://127.0.0.1:10086
git config --global https.https://github.com.proxy socks5://127.0.0.1:10086
在c盘的C:\Users\Administrator下的.gitconfig打开可以看到,已加入的代理。

取消代理:

git config --global --unset http.proxy 
git config --global --unset https.proxy 

查看当前代理:
git config -l

设置完,在系统文件路径下:C:\Users\Administrator(用户名).gitconfig 打开后最后几行可以看到配置的代理信息。
而用sourcetree配置的代理是不会作用到上面这个.gitconfig文件中的,但是可以一直使用。

注意

如果以后出现同样错误,记得改回去,毕竟不是每次都用科学上网

猜你喜欢

转载自blog.csdn.net/chungehenyy/article/details/130709079
今日推荐