Git 拉失败: 调用失败服务器文件意外结束

我尝试用 Android Studio 的内置按钮执行一个 git pull,但是失败了:

Git Pull Failed
Invocation failed Unexpected end of file from server
java.lang.RuntimeException: Invocation failed Unexpected end of file from server
at org.jetbrains.git4idea.http.GitAskPassXmlRpcClient.askUsername(GitAskPassXmlRpcClient.java:55)
at org.jetbrains.git4idea.http.GitAskPassApp.main(GitAskPassApp.java:66)
Caused by: java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:851)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:848)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1593)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1498)
at org.apache.xmlrpc.DefaultXmlRpcTransport.sendXmlRpc(DefaultXmlRpcTransport.java:87)
at org.apache.xmlrpc.XmlRpcClientWorker.execu... (show balloon)

这种做法可能失败的原因是什么?

46846 次浏览

The error originates from the Android Studio Preview version (Bumblebee, Chipmunk, etc.). You can either update your Android Studio to a newer version, or you can use the inbuilt terminal and type the command below:

$ git pull

You may be prompted to re-enter a password or token.

You can enable the option "Use credential helper" in Android Studio's Preferences menu.

The option is located at Preferences -> Version Control -> Git

Using the credential helper did not work for me, and neither did deleting the .gitconfig file in my C:\User folder.

What worked for me was installing a new version of Android Studio, and opted out of importing previous version settings.

If someone is facing this issue in Android Studio Preview, do the following:

Preference -> Git -> Check Use credential helper (if not checked)

This worked for me:

  1. Open Terminal in Android Studio. Hit this command:

    git config credential.helper store
    

    It will ask for a password, enter your password. This could also be an access token.

  2. Enable "Use Credential Helper" in Settings -> Version Control -> Git.

After these 2 steps, you will be able to Pull, Push, and Commit.

Following steps:

Delete .gradle and .idea

Delete remote URL from git tab

go to git in android studio prefs and select use credential manager

Now add your remote URL in the git tab again and "FETCH"

Using the terminal, type this

git clone https://git-example-service/project-url.git

Then you will be prompted to enter your account password. Once you enter your password, the issue should be resolved.

This resolved the problem for me:

File -> Settings -> Version Control -> Git -> Use credential helper (set it to checked) -> push the Apply button.

P.S. I use a token for access.

Use these steps to git over HTTPS not SSH:

git config credential.helper store

You'll be requested the credentials username/token or pass. Check this in Preferences > GIT > Use Credential Helper

Just restart Android Studio.

What worked for me was going to Settings -> Version Control -> GitHub -> Remove your account

Then I logged in again with a new token.

File -> Settings -> Version Control -> Git -> Use credential helper (set it to checked). Then git pull after then git push

File -> Invalidate Caches...

Check "Clear VCS Log caches and indexes" box

Click "Invalidate and Restart"

In Ubuntu, 'Credential Helper' AND 'File -> Invalidate Caches' not helped me, I just DELETED the FILE '/home/YOUR USERNAME/.cache/Google/AndroidStudio2021.2/tmp/intellij-git-askpass-local.sh'. now its working

git init
git remote add origin LINK_HTTPS_ON_GIT
git add .
git commit -m "NhoPV BackUp"
git fetch

Login

git push origin YOUR_BRANCH