46
votes

I'm using Visual Studio, and the GitHub Extension. I am able to sign in, then clone my team's repository, and then pull changes successfully.

When it comes time to push my changes back to remote, I get a blank command prompt appear on the screen briefly, and then the following errors in the output window:

Error encountered while pushing to the remote repository: Git failed with a fatal error.

fatal: AggregateException encountered. One or more errors occurred.

error: cannot spawn askpass: No such file or directory

fatal: could not read Username for 'https://github.com': terminal prompts disabled

EDIT: pushing via the command line works, as does pushing via the GitHub desktop application, just not within this extension.

Any ideas why this might be happening? I can't see why it needs the Username given that I have signed into the extension.

10
Do you use a password extension? It might be blocking the User Access Control. You could also revise your remote url to include your username. stackoverflow.com/questions/6565357/…Taylor Ackley
@TaylorAckley thanks, I thought I tried everything in the other questions but didn't see this one hiding away. Adding the username to the remote url was the only thing that worked (I have no password extension or anything unusual like that). If you add it as an answer I'll accept it.Matt
I was able to solve this by getting a 'access token' credential (that works between Visual Studio and Azure-Devops) and re-booting the computer hosting Visual Studio. I don't know if this is a general solution or not.JosephDoggie

10 Answers

33
votes

As per my comment. You can include your username in the remote URL (similar to FTP).

Example without password (SSH):

git remote set-url origin git@github.com/username/repo.git

Example with password (https)

https://name:password@github.com/username/repo.git

Source: Git push requires username and password

Updated 5/14/2018 to correct github.org to github.com in the original answer

11
votes

Check that Windows does not have a pending update. If it does, update and restart.

10
votes

This worked for me:

Deleting the file %localAppData%\GitCredentialManager\tenant.cache and then re-trying your logon.

3
votes

In windows go to credentials manager and check if generic credentials list has the below entries

git:https://github.com

https://github.com

If these entries are not present add these entries with username and password and it should work.

3
votes

This happened to me when syncing. Updating visual studio to the latest version did it for me.

2
votes

What worked for me was to disconnect from all the existing connections in Visual Studio, remove them one-by-one and connect from scratch. Then immediatelly I was able to clone the repository again.

2
votes

Using Windows Credential manager

**Windows Credential manager**

After seeting username, password in Windows Credential Manager, set git config to read from credential manager. Open gitbash, run command:
git config --global --add credential.helper manager

1
votes

I faced the same issue after I have only TLS1.2 enabled on my PC. After enabling TLS 1.1, SSL.x the issue was resolved. For enabling and disabling I used IISCrypto software. Hope that helps the team and other users.

1
votes

In my case the same issue coming on below scenario:

We are under corporate network. So we have our own proxy. When we try cloning we cant able to download due to same error.

I added proxy url in our git config.

[http]
 proxy=http://YourNameHere:YourPasswordHere@proxy.aaa.com:6050/
 sslVerify = false

[https] 
proxy=http://YourNameHere:YourPasswordHere@proxy.aaa.com:6050/
 sslVerify = false

Issue disappears and i can do all git operations.

0
votes

I have updated my Visual studio 2017 and restarted it. Now it's working fine.My updated Visual studio version: