Failed to fetch from the remote repository. See the Output window for more details.I was actually authenticated, but not authorized to fetch from the VSTS Git project repository.
Upgrade Visual Studio from 15.3.3 to 15.3.4 might fix the VSTS authentication issueThere is an open topic for TFS Launching VS with Source Control Explorer open.
I performed few steps following the topic and hoping to fix the Git for Windows issue, but with no success. There are the steps I performed, I upgraded 15.3.5 then reinstalled the git for windows client and removed the local appdata related to VS and did
1.Close all instances of VS
No success at the end of the exercise. So I decided to go with workaround approach to use the VSTS Personal access tokens since fetching.
Register Visual Studio Team Services Personal access token
Login to Visual Studio Team Services Project and go to your very top right of the browser where VSTS Account Setting are then select security settings.
Go to Security -> Personal Access Tokens -> Add
Add name and select scopes and expiry period.
Once created, make sure you copy the token now. You cannot get the value ever again.
VSTS project git pull or clone with Personal access token
Now we have to open the command prompt and open do `git pull` or `git clone` from the cmd so we get the basic authentication login from git for windows. Note: If you are prompted with windows credentials popup just close it and new command line will appear for name and password.
run cmd.exe C:\Projects\SharePointIntranet (dev) λ git pull Logon failed, use ctrl+c to cancel basic credential prompt. Username for 'https://xxintranet.visualstudio.com': ANY_VALUE_EG_YOUR_NAME Password for 'https://[email protected]': YOUR_VSTS_PERSONAL_ACCESS_TOKEN ...
Store VSTS Git Personal access token to the Windows credentials manager
Do not close the cmd window yet, but instead store your credentials in the Windows Credentials Manager by executing the command bellow:
... C:\Projects\SharePointIntranet (dev) λ git config --global credential.helper manager
So next time Git for Windows will use these credentials to authenticate and they are securely stored to the Windows Credentials Manager. If you are using OS different than windows there is the Stackoverflow topic on how to cache or store git credentials
Use Visual Studio 2017 with the Git for Windows and the VSTS Personal access token
Now since we already stored the credentials, the Visual Studio 2017 Team Explorer (Git client) should pick them up by default and you should be able to use the client without any additional efforts. This is valid in case when you have only one version for the Git client or you use the Command line (CMD) with the same Git version used with the Visual Studio 2017 Team Explorer.
Windows Credentials Manager might has saved wrong or different credentials and use them instead
Make sure the Windows Credential Manager does not have any other Git credentials saved because it might use them instead of the newly created. Go to Windows -> Control Panel -> User Accounts -> Credential Manager. Under Generic Credentials delete any credentials related to git and leave only the one you saved with the `git config --global credential.helper manager` command.