git pull works from terminal window, but Pull button in GUI prompts for credentials
Asked by Steve Grimes:

I'm using Windows 10, git version 2.19, and SourceTree 2.6.10 (although I've gone all the way to 3.06 and still have this issue.)

\\We recently changed the host of our repositories to Azure DevOps/TFS.

In Sourcetree, I modified the repository path using "repository settings".

When I go to the Terminal window (the first time) and issue a "git pull", the Git Credential Manager (which I installed with git version 2.19) prompts me to log in in via my companies portal login. The pull then works. It works after that too, no repeated login required.

The Pull button however, prompts me for a username and password (which I have iteratively cleared by deleting the passwd and userhosts files from C:\\Users\\\*mylogin\*\\AppData\\Local\\Atlassian\\SourceTree.)

Whether I let it prompt me or not, the Pull button then fails with a bunch of these messages: "fatal: ArgumentException encountered. An item with the same key has already been added." And a few of these messages: "Authentication failed for '[https://dev.azure.com/zzzzzzzz/xxxxxxx/_git/MyRepo/'"](https://dev.azure.com/zzzzzzzz/xxxxxxx/_git/MyRepo/'"?) I've used every combination of credentials I can think of (full email address, AD network username, etc.)

I have two other machines I develop on - a Server 2012 box and a Server 2016 box. These work fine! I followed the same steps outlined above, and Sourcetree doesn't prompt me for credentials.

My gut feel is that my Windows 10 Sourcetree is unaware that the Git Credential Manager has already authenticated me using a Personal Access Token that it has created/stored.

Tortoise Git works fine on this box; no authentication prompts.

In my SourceTree options, I've tried both settings of "Allow Sourcetree to manage my credentials via the Git Credential Manager". I've deleted all the "Git Saved Passwords" in the Authentication tab. (There is one there now, from my latest iteration of this.) I've deleted everything that seems extraneous from the WIndows Credential Manager - Generic set. (I've left the one that I think represents my valid git/Azure/TFS Personal Access Token.)

Any suggestions on what I might try next?


Answers:
author: Mike Corsaro
body: Hello! Could you check the version of the git-credential-manager and try downloading the latest version? Thanks!

comments: author: Steve Grimes
body: Thanks Mike. I got it working!

I was at git for windows 2.19.1, but went ahead and re-installed it. (I also uninstalled Sourcetree and then installed SourceTree 3.0.8) Here's what finally worked. I've created a personal Access Token on the TFS site but still couldn't get any combination to work using SourceTree. I then wiped out my local git directories, and did my first repo clone using Tortoise. It handled the security authentication via the git credential manager.) I then did an "Add" repo in SourceTree. It prompted me one time, for credentials where I put in my username (without any "@.stuff.com") any PAT as the password.

Everytime it asks for credentials now it has a greyed out "username" which isn't my username, but, the PAT seems to be consistently working for the password.

Thanks. SourceTree is still the best interface for my git paradigm, but boy is it a pain sometimes.


Tags: azure

credential

git

token