常见问题——VS中使用Git报错

问题1

VS2019使用Git将代码推送远程仓库时弹出Github的输入用户名和密码的窗口,
在我输入用户名和密码后,显示未推送成功,
输出窗口内容如下:

正在推送 master
发布到远程存储库时遇到错误: Git failed with a fatal error.
TaskCanceledException encountered.
   ��ȡ��һ������
cannot spawn /c/program files (x86)/microsoft visual studio/2019/enterprise/common7/ide/commonextensions/microsoft/teamfoundation/team explorer/Git/mingw32/libexec/git-core/git-askpass.exe: No such file or directory
could not read Username for 'https://github.com': terminal prompts disabled
Pushing to https://github.com/shanzm/ASP.NET-Core.git

【解决方案】

修改仓库的.git文件夹中的config文件,将文件中的:

url = https://github.com/shanzm/ASP.NET-Core.git

修改为:

url = https://用户名:密码@github.com/shanzm/ASP.NET-Core.git

再次推送,显示成功,完美解决问题!

问题2

前一段时间,公司的笔记本,老是报错:"HttpRequestException encountered."

当时的解决方案是,安装GCMW,更新Windows的git凭证管理器

下载地址:https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.14.0

问题3

前一段时间,打开一个旧项目,默认使用的是VS2015,修改代码后推送远程时候报错”克隆远程存储库时遇到错误: Unsupported URL protocol“

以前是遇到过这样的报错,当时是因为使用的Git Bash采用SSH协议克隆到本地,而VS中的Git插件是不支持SSH协议,只支持HTTP协议,所以在这种情形下会报上面的错误,

但是这个仓库我就是使用HTTP协议从远程克隆,我又删掉该仓库,使用VS中的Git插件,以HTTP协议从远程克隆,发现也会报上面的错误,

所以应该不是Git协议的问题,尝试了一些其他的方法,也没有解决问题,

怒而删除VS2015,直接使用Vs2019打开!

问题4

fatal: unable to access 'https://github.com/username/username.github.io/': OpenSSL SSL_read: Connection was reset, errno 10054

解决方法:

git config --global http.sslVerify "false"
git config --global https.sslVerify "false"

问题5

在另外一台电脑上基于ssh克隆某个仓库,报错如下:

$ git clone git@github.com:shanzm/XXXX.git
Cloning into 'XXXX'...
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s.
Please contact your system administrator.
Add correct host key in /c/Users/计算机账号/.ssh/known_hosts to get rid of this message.
Offending RSA key in /c/Users/计算机账号/.ssh/known_hosts:1
Host key for github.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.

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

依据字面意思,远程主机秘钥已经修改,而本地保存的还是上一个系统的秘钥。
删除存放ssh公钥秘钥路径下的known_hosts文件,或者删除日志中提示known_hosts的第几条的记录。然后重新执行

重点是这一句Offending RSA key in /c/Users/计算机账号/.ssh/known_hosts:1
找到C:\Users\计算机账户\.ssh,删除上述第一行,重新克隆即可

posted @ 2020-07-05 23:19  shanzm  阅读(1012)  评论(0编辑  收藏  举报
TOP