37

Here is my error on visual studio. I can't figure out if there is a config to fix this. Additionally I am restricted from installing git command line tools.

Error encountered while pushing to the remote repository: Git failed with a fatal error.
fatal: HttpRequestException encountered.
   An error occurred while sending the request.
error: cannot spawn askpass: No such file or directory
fatal: could not read Username for 'https://github.com': terminal prompts disabled
Vasilis G.
  • 7,556
  • 4
  • 19
  • 29
Zaldimmar
  • 373
  • 1
  • 3
  • 7
  • 2
    Possible duplicate of [Git failed with a > fatal error. could not read Username for](https://stackoverflow.com/questions/47997966/git-failed-with-a-fatal-error-could-not-read-username-for) – phd Feb 23 '18 at 22:16
  • 5
    This is not a duplicate of that issue. Daedalon is correct; GitHub's removal of pre-TLS 1.2 have caused this issue. – Edward Thomson Feb 25 '18 at 01:09
  • 1
    I'd recommend changing the accepted answer to Lachezar's answer, for reasons mentioned in Suamere's comment on the currently(3/2/18) accepted answer. – BMB Mar 02 '18 at 18:15

10 Answers10

32

Cause: GitHub updated their security requirements on the server side. They no longer support TLS 1.0 and 1.1, only 1.2. Older Git Credential Manager for Windows versions used 1.0.

Solution: Update Git for Windows. Version 2.14.3 and newer include an up-to-date Git Credential Manager for Windows.

Alternatively you can update only the Git Credential Manager for Windows itself. It supports TLS 1.2 from version 1.14.0 onwards.

Daedalon
  • 590
  • 4
  • 6
  • 7
    This is great info, but since you should update VS anyway, Lachezar's answer worked better for me. Updaing VS did indeed solve all of the issues you talked about, without having to finagle with my system in manual ways. – Suamere Feb 25 '18 at 18:01
  • 3
    VS Update did it for me – Ozan BAYRAM Mar 01 '18 at 14:15
  • 1
    @daedalon I have installed VS enterprise 2017 today which is showing up to date. But still while trying to clone a VSTS git repo, I am getting "Git fatal error. HttpRequestException. Cannot spawn..". Can you please give suggestion for this? – Rohit Garg Mar 13 '18 at 16:20
  • 1
    Hi @RohitGarg, sounds like that could be a different error. If your error message is identical to the one in the original question, double-check that you have the latest version of VS. If you do, you may consider updating Git for Windows or Git Credential Manager separately. – Daedalon Mar 16 '18 at 19:34
  • 2
    For me, it got fixed by copying the two dll files I.e. libeay32.dll and ssleay32.dll from \Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\bin\" folder to the "\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\git-core\" folder – Rohit Garg Mar 19 '18 at 16:07
32

Simply update your Visual Studio to the latest version and this should be fixed. Worked for me.

Lachezar Lalov
  • 477
  • 6
  • 6
  • 4
    Thank you Lachezar. Specifically, VS 2017 version 15.5.7 (release 2/20/18) mentions this fix: "We have updated the Git and the Git Credential Manager components" – Emilio Feb 27 '18 at 20:50
  • 1
    Thanks, worked perfectly. This should be the accepted answer. – BMB Mar 02 '18 at 18:12
  • 2
    I tried this answer first, but had to update Git for Windows before it worked again. – Pieter Heemeryck May 31 '18 at 12:00
  • 1
    I have v15.7.6 and still have this issue. And I updated Git for Windows and Credential Manager too. Still same error as OP. – smoore4 Aug 10 '18 at 14:24
  • thanks for a tip! worked for me. Also there was a pending update of Windows, after which I updated Visual Studio – Yury Kozlov Jan 24 '19 at 04:26
3

Git Credential Manager for Windows v1.17.1 fixes the issue on BitBucket. Note the one comment:

Bug Fixes:

Fixes a bug related to Bitbucket authentication (thanks to @Foda for contributing the fixes).

https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases

smoore4
  • 4,520
  • 3
  • 36
  • 55
2

This is because Github disabled TLS v1.0 and v1.1,you can read the notice on Github Engineering, here is the link Weak cryptographic standards removal notice.

From the linked page:

Last year we announced the deprecation of several weak cryptographic standards. Then we provided a status update toward the end of last year outlining some changes we’d made to make the transition easier for clients. We quickly approached the February 1, 2018 cutoff date we mentioned in previous posts and, as a result, pushed back our schedule by one week.

...

Visual Studio ships with specific versions of Git for Windows and the Git Credential Manager for Windows (GCM). Microsoft has updated the latest versions of Visual Studio 2017 to work with TLSv1.2 Git servers. We advise users of Visual Studio to upgrade to the latest release by clicking on the in-product notification flag or by checking for an update directly from the IDE. Microsoft has provided additional guidance on the Visual Studio developer community support forum.

Sheridan
  • 68,826
  • 24
  • 143
  • 183
Nz_z
  • 21
  • 2
1

Check if you have proper configuration. It might be possible if all are okay, there is a wrong email. Inside Team explorer check Global Settings for email.

  • 1
    Git failed with a fatal error. could not read Username for 'https://test.visualstudio.com': terminal prompts disabled – Asif Hameed Jun 08 '18 at 09:21
1

In my case, updating git and copying the bin directory cannot fix the error. My solution is checking your git config. First, open git bash. Second, check git config. git config -l The http.proxy and https.proxy would make you cannot update the project successfully. And if you use vpn, and make the 1080 port open, that would make the upload not so smoothly.(Only the case that your vpn is slow)

tyrantqiao
  • 319
  • 4
  • 7
1

In my case the above didn't work since my google email address for bitbucket had 2 factor authentication. So I had to create a bitbucket app token and in the origin https url I had to put the token that was generated like so https://username:appToken@bitbucket.org/repo/test.git

recnac
  • 3,744
  • 6
  • 24
  • 46
lymberazo
  • 453
  • 6
  • 13
1

You code written above is right, but if you can pull and can't push, but you can push just in console and not in VS, and you are behind a corporate proxy, then you might try another approach. It may work for you:

  1. Create GitHub token: https://help.github.com/en/articles/creating-a-personal-access-token-for-the-command-line#creating-a-token
  2. In the .gitconfig file write:

    [credential] 
    authority = *the-token*"
    
  3. Search for the file .gitconfig by command: git config --list --show-origin

bart cubrich
  • 1,184
  • 1
  • 14
  • 41
Daniel
  • 11
  • 1
0

Git bash on windows was giving trouble even after typing in the password in the pop up window. I tried with Git Gui and it works fine.

Prabhanjan Naib
  • 201
  • 3
  • 12
0

open your project folder path, right-click on the folder, select Git Bash, in that type the command

git config --global http.sslVerify false

git command

Then try to Sync, fetch and pull, it will work

  • This is not a viable solution, you are setting `http.sslVerify` globally to false which compromises security. – imgkl Feb 02 '21 at 11:29