Android Studio git pull failed
使用 Android Studio git 提交代码时报错,错误信息如下:
Git Pull Failed
Invocation failed Unexpected Response from Server: Unauthorized
java.lang.RuntimeException: Invocation failed Unexpected Response from Server: Unauthorized
at org.jetbrains.git4idea.nativessh.GitNativeSshAskPassXmlRpcClient.handleInput(GitNativeSshAskPassXmlRpcClient.java:34)
at org.jetbrains.git4idea.nativessh.GitNativeSshAskPassApp.main(GitNativeSshAskPassApp.java:30)
Caused by: java.io.IOException: Unexpected Response from Server: Unauthorized
at org.apache.xmlrpc.LiteXmlRpcTransport.sendRequest(LiteXmlRpcTransport.java:231)
at org.apache.xmlrpc.LiteXmlRpcTransport.sendXmlRpc(LiteXmlRpcTransport.java:90)
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.nativessh.GitNativeSshAskPassXmlRpcClient... (show balloon)
我们使用 git clone 下来的项目,按理说应该可以正常使用 git 了才对呀,为什么修改完代码执行 pull 时报错呢?
我们自己搭建 git 服务器时,并没有把我们的公钥上传到 git 服务器。(像 GitHub 一样,在本地先生成一个公钥,然后将公钥粘贴到我们 GitHub 的 Settings -> SSH and GPG keys 里面)
每次下载的时候,需要输入 git 账户的密码,所以使用 AndroidStudio 默认设置就 pull 失败了。
修改 AndroidStudio 设置:
File -> Settings -> Git -> SSH executable: 由原来的 Native 修改为 Built-in 即可。