IDEA(或Android Studio)推送(push)代码报错 unable to read askpass response from ‘C:\Users\Urasaki\AppData\Loc

推送给代码报错 unable to read askpass response from 'C:\Users\Urasaki\AppData\Local\Google\AndroidStudio2021.1\tmp\intellij-git-askpass-local.sh',具体报错见以下内容

Invocation failed Unexpected end of file from server
java.lang.RuntimeException: Invocation failed Unexpected end of file from server
	at org.jetbrains.git4idea.GitAppUtil.sendXmlRequest(GitAppUtil.java:30)
	at org.jetbrains.git4idea.http.GitAskPassApp.main(GitAskPassApp.java:58)
Caused by: java.net.SocketException: Unexpected end of file from server
	at java.base/sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:866)
	at java.base/sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:689)
	at java.base/sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:863)
	at java.base/sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:689)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1615)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
	at org.apache.xmlrpc.DefaultXmlRpcTransport.sendXmlRpc(DefaultXmlRpcTransport.java:87)
	at org.apache.xmlrpc.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:72)
	at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:194)
	at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:185)
	at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:178)
	at org.jetbrains.git4idea.GitAppUtil.sendXmlRequest(GitAppUtil.java:27)
	... 1 more
error: unable to read askpass response from 'C:\Users\Urasaki\AppData\Local\Google\AndroidStudio2021.1\tmp\intellij-git-askpass-local.sh'
bash: /dev/tty: No such device or address
error: failed to execute prompt script (exit code 1)
fatal: could not read Username for 'https://gitee.com': No such file or directory

我用的码云(或github)推送代码,当我改了账户的密码后,推送代码一直失败,报错 unable to read askpass response from。

有两个这个原因,以下原因也可能造成推送代码失败

1、码云(或github、gitlab)账号信息变动(比如:修改可账号的密码或者用户名)。

2、IDEA(或Android Studio)中代码管理工具Git没有设置ssh key。

解决方案

方案一

1、找到在项目根目录中的.git文件(是隐藏的,先让他显示出来,见下图一和下图二)

IDEA(或Android Studio)推送(push)代码报错 unable to read askpass response from ‘C:\Users\Urasaki\AppData\Loc_第1张图片

IDEA(或Android Studio)推送(push)代码报错 unable to read askpass response from ‘C:\Users\Urasaki\AppData\Loc_第2张图片

2、找到.git文件中的config文件(见下图一),打开这个文件,找到这一项([remote "origin"]),如果红圈处的那一行是以url = https://(或url = http://)开头的,需要修改这里(见下图二),如果红圈处的那一行是以url = ssh://git@开头的,那请查看方案二。

[remote "origin"]
    url = https://xxxxxxxxxxx:[email protected]/urasaki/RxJava2AndRetrofit2.git
    fetch = +refs/heads/*:refs/remotes/origin/*

IDEA(或Android Studio)推送(push)代码报错 unable to read askpass response from ‘C:\Users\Urasaki\AppData\Loc_第3张图片

IDEA(或Android Studio)推送(push)代码报错 unable to read askpass response from ‘C:\Users\Urasaki\AppData\Loc_第4张图片

方案二

如果项目根目录下的.git文件中的config文件(见下图一),打开这个文件,找到这一项([remote "origin"],见下图二),红圈处的那一行是以url = ssh://git@开头的,那就是因IDEA(或Android Studio)中代码管理工具Git没有设置ssh key(或者设置的ssh key不对)引起的推送代码失败。

IDEA(或Android Studio)推送(push)代码报错 unable to read askpass response from ‘C:\Users\Urasaki\AppData\Loc_第5张图片

IDEA(或Android Studio)推送(push)代码报错 unable to read askpass response from ‘C:\Users\Urasaki\AppData\Loc_第6张图片

解决方法:

1、如果是Mac 电脑请查看博客Mac Git 如何设置ssh key_ErwinNakajima的博客-CSDN博客

 如果是Windows 电脑请查看博客Git配置SSH KEY_萧木易的博客-CSDN博客_git sshkey

配置完成之后就可以正常推送(push)代码了。

你可能感兴趣的:(android,studio,intellij-idea,java)