30

I've been struggling with that issue for a couple days now.

I'm unable to connect to my Git project (stored in VisualStudio.com) from a specific computer (it works on my second PC). Whenever I try to Sync or Clone my repository, VS2017 asks for my user credentials (twice) and the I get the following error :

Error: cannot spawn askpass: No such file or directory Error encountered while cloning the remote repository: Git failed with a fatal error. could not read Username for 'https://.visualstudio.com': terminal prompts disabled

Can't remember if I changed anything that could've caused that...

danbord
  • 3,605
  • 3
  • 33
  • 49
  • Just had this issue. In my case I was able to access it fine yesterday but not today. I modified my .gitconfig to use SSH, then got prompted, closed it without connecting, set my .gitconfig back to how it was and retried. It then worked again. – sr28 Apr 24 '18 at 15:10

13 Answers13

32

It’s mainly caused by the credentials have been remembered by Credential Manager. You should remove the credentials for xxx.visualstudio.com which have been stored in Credential Manager.

Such as if the pc’s OS is windows, you can open Credential Manager -> Windows Credentials -> under Generic Credentials -> remove the credentials like git:https://xxx.visualstudio.com.

enter image description here

Then clone again, git will let you input the credential for the repo. After inputing the username(email address) and password which can access the VSTS account, the repo should be cloned successful.

Marina Liu
  • 36,876
  • 5
  • 61
  • 74
  • 1
    I followed the steps but it did not work for me.I am using VS2017 and trying to connect to VSTS git project. I getting below error Error encountered while pushing to the remote repository: Git failed with a fatal error. Win32Exception encountered. Failed to write credentials cannot spawn askpass: No such file or directory could not read Username for 'https://xxxxxx.visualstudio.com': terminal prompts disabled Pushing to https://xxxxxx.visualstudio.com/_git/StockTrace – Anuranjan Srivastav Feb 19 '18 at 09:24
  • It doesn't work for me when building in TFS. Suppose the submodule is configured using FQDN (i.e. https://subdomain.domain.com/tfs/DefaultCollection/Project/_git/Repository2). When TFS build cloning the git repository, it uses subdomain only (https://subdomain/tfs/DefaultCollection/Project/_git/Repository1). I have no idea why it uses subdomain only during cloning. FYI, I configured TFS server the public url to use FQDN. I've tried to clear generic credential many times and still no luck. I can also reproduce the issue by using the same way. – iroel Apr 17 '18 at 04:22
  • Just tried again, the TFS build succeeded when it uses the same URL. In this case, I use subdomain only just like TFS build uses. – iroel Apr 17 '18 at 07:10
  • 1
    I changed my password with VS open -- won't do that again -- and Git failed with an authentication error. I removed my 2 git:... credentials, in Credential Manager and VS prompted for a username/password when syncing. Problem solved. – J. Horn Jul 06 '18 at 13:06
  • This in combination with the @Matstar answer solved it. Needed to do both (remove tenant.cache +remove credentials in manager) – BobbyTables Sep 24 '19 at 12:21
  • In addition to this I had to run Visual Studio as an Administrator for the first time for the repo to sync correctly. – Gruss Apr 30 '20 at 14:06
  • Along the same line, removing the credential for "git:https://github.com" helped fix the error "fatal: could not read Username for 'https://github.com': terminal prompts disabled" that I encountered in a Azure DevOps pipeline. – Stephen Pham Jun 21 '20 at 05:03
19

I did not have any git credentials registered with Windows Credentials and I still received this error, even after selecting my windows user account in the VS User Dialog popup.

After a day of trying different things like re-installing GIT for windows, I managed to fix this issue by deleting a this file: "C:\Users(profile)\AppData\Local\GitCredentialManager\tenant.cache".

On the next retry, a GIT entry showed up in my Windows Credentials generic list. See Issue

Matstar
  • 402
  • 3
  • 6
  • I tried this, it did not work for me. I had to get the latest git-credential-manager.exe and put it in the VS2017 git-core folder . – MikeZ Oct 26 '18 at 00:01
  • I updated the credential manager, and it did not resolve my issue, but glad to see it worked out for you. – Matstar Oct 27 '18 at 10:40
  • Today we connected our DevOps account to our AAD. After that we could not longer clone our repos. Your answer was the solution for this issue. Thanks a lot. – zgue Dec 12 '18 at 13:48
  • delete all git stored credentials from credential manager and delete tenant.cache file work for me. thanks! – purplesoft Mar 09 '19 at 10:37
6

Simply update your Visual Studio to the latest version. This bug was reported and fixed with the latest updates. Worked for me.

Lachezar Lalov
  • 477
  • 6
  • 6
  • And should that not be possible because you have no admin rights; git remote set-url origin username:password@github.com/username/repo.git - that worked for me. Note: Will store your github password in plaintext in ./git/config – Stefan Steiger Feb 26 '18 at 09:36
  • I have the latest version of VS and this is still happening for me. – user2847376 Oct 29 '18 at 18:29
  • I'm using a version of VS2017 updated 9 months after you made this suggestion... and the problem is still there. – Mike Gledhill Jan 07 '19 at 13:45
  • seems like a VS issue, I tried in VS2017 didn't work, I saw this and said hey let me try on VS2019 since I also have it installed and it worked (might be useful for someone). – solujic Oct 23 '19 at 12:07
4

I had a similar problem.

Push from within VS2017 would fail, I was getting an error spawning git-askpass.exe

I fixed it by copying/replacing all the files in the VS2017 git-core folder with the files from the git-core folder created by the Git installation.

I might have only needed the new git-credential-manager.exe, but I replaced everything.

So far, no problems.

VS2017 folder: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\git-core

Git installation folder: C:\Program Files\Git\mingw64\libexec\git-core

MikeZ
  • 1,155
  • 1
  • 13
  • 20
3

Okay after much heartache I managed to resolve the issue (at this point had I tried everything including deleting accounts from Credential Manager).

I started up Visual Studio 2017 and then I opened my repository and next went to the Team Explorer tab for the repository.

I left-clicked on the Sync option and then again on the sync link button to initiate the pull/push actions. This caused Visual Studio to display a dialog box asking me to select my credentials.

However what I did to resolve the issue was to first "Forget" the account that I was trying to use in the first place (left-click on the 3 dot icon on the right) and then I was prompted for the username and password again - enter the correct one's and it should all sync up nicely now!

Trevor
  • 1,561
  • 1
  • 20
  • 28
2

The combination of clearing credentials and deleting tenant.cache has worked for me in the past - I was able to force a reconnect to my *.visualstudio.com git repo and get things working entirely from within VS2017. Had to do more today with a new VS2019 install though. Key in my case was "terminal prompts disabled" portion of the error (similar to Anuranjan Srivastav's comment on the accepted answer). Doing a simple "git fetch" using command line tools (after clearing out credentials) did the trick for me this time - prompt for credentials came up and all was set aright.

2

In my case this happened when my VS 2019 license expired. I approached helpdesk and they gave a new license and then I activated it and when I tried to Fetch using VS 2019 the problem started. I got below error message when I did Fetch in VS 2019.

Git failed with a fatal error. could not read Username for 'https://xxx.visualstudio.com': terminal prompts disabled

Below are the steps I did

1) I went to Credential Manager and deleted the entry for https://xxx.visualstudio.com.

2) Installed GIT Credential Manager for Windows. https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases

3) Open command prompt and went to my local working directory.

4) Gave command git fetch and pressed enter and I got few messages that said Fetch was success.

5) Re-opened VS 2019 and did Fetch and now it worked. I also tested Pull, Push and so on and everything works.

Ziggler
  • 3,361
  • 3
  • 43
  • 61
2

I had a similar problem.

I solved it by the following steps:

  1. Connect to your remote Azure DevOps repository from Git Bash.
  2. Try Git commands for Sync/Clone/Pull/Push (ing) the repository.
  3. Git Credential Manager will ask the user credentials (twice in my case). Provide the details.
  4. It will ask for Username and Password credentials Username and Password
  5. This Username and Password can be generated from here (Clone -> Generate GIT Credentials): Generate GIT Credentials
  6. Try Git operations from Visual Studio. (It should work)

Please note that it will ask for Username Password every time you perform any of the Git operations (pull/push/fetch/clone etc).

I solved it by the following:

Run

git config --global credential.helper store

then run

git pull

provide a username and password. These details will then be remembered.

Kush
  • 212
  • 2
  • 5
0

You should delete credential and add with the same url new, but instead of password for credential You should use Personal Access Tokens, which you can generate git:https://xxx.visualstudio.com. -> security -> Personal Acccess Token. You can get it by select existing token andpush to regenerate.

enter image description here

and create new

Andrew
  • 26,706
  • 9
  • 85
  • 101
0

I had the same issue and doesn't fix doing anything above and fixed by doing following,

1)go to souce code location ===> .git folder ==>config file ==> open it.

2)go to [remote "origin"] url ="dev.azure.com/xxxx/_git/yyyy" copy that url

3)open the fresh browser [icongnito :)] open the copied url.

4)It ask to login just login from your commiting credential. login and go to files and click on clone button.you see in image enter image description here

5)without doing any modification to that url.you may wonder that your user name is not there in prefix.but dont worry copy with that username.

6)past that URL in step 2 location.

7)I also remove C:\Users(profile)\AppData\Local\GitCredentialManager\tenant.cache file [added later] it works at least for me.

Side note : anyone know why that url prefix with site created user name instead of my user name ?

Prageeth godage
  • 4,054
  • 3
  • 29
  • 45
0

Updating git to latest version and running in Administrator command window helped me

Abhishek Agrawal
  • 2,183
  • 1
  • 17
  • 24
0

I had the same issue with Visual Studio 2017 + a Git repo hosted at Bitbucket.

On each Git transaction, I got the Atlassian Bitbucket login window, where I entered the correct user/pass, then got the error: could not read Username for 'https://bitbucket.org': terminal prompts disabled

What helped for me is first manually logging into Bitbucket in Internet Explorer, and possibly closing/accepting all the notifications/popups that were waiting for me. After that, Git from VS2017 worked again.

I think they were preventing the VS Git login process to complete successfully.

Andrew
  • 817
  • 2
  • 10
  • 21
-1

I experienced same issue (with VS2017), I solved it by deleting the following Git folder

C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git

After deleting it I performed some git operation and then Visual Studio asked my credentials for git then it worked fine.

Krishnan
  • 66
  • 10