Trying to clone repository, can't supply password
Asked by Gibran Shah:

Hello,

I'm working in SourceTree and I cannot clone my repository. Here's what I enter into the dialog:

![trying to clone promcom repo.png](/t5/image/serverpage/image-id/14811i61E0C029F5CE9B7F/image-size/large?v=v2&px=999 "trying to clone promcom repo.png")

But it tells me "This is not a valid source path / URL". When I click on the Details button, it tells me "Invalid username or password...".

I have confirmed that the url is correct and that my username is correct. I'm trying to figure out how to supply the password. Can you please help me figure out how to supply the password.

Thanks.


Answers:
author: Gibran Shah
body: Hi Michael,

I updated to the latest version of SourceTree. In addition to that, I entered the URL without my username. This time it prompted me for login credentials.

But now my login credentials won't work! I keeps re-prompting me! I should enter the same login credentials that I use to log into my BitBucket account, shouldn't I?

comments: author: Gibran Shah
body: UPDATE:

The error I get is slightly different now:

Command: git -c diff.mnemonicprefix=false -c core.quotepath=false ls-remote https://gibran_shah@bitbucket.org/gibran_shah/riskalive.git  
Output:  
Error: Logon failed, use ctrl+c to cancel basic credential prompt.  
error: unable to read askpass response from 'C:\\Users\\gshah\\AppData\\Local\\SourceTree\\app-2.4.7\\tools\\Askpass.exe'  
bash: /dev/tty: No such device or address  
error: failed to execute prompt script (exit code 1)  
fatal: could not read Password for 'https://gibran_shah@bitbucket.org/': No error

This seems to say it is trying to get the password from Askpass.exe. \<-- Not sure what that it or why it's failing.


author: minnsey
body: Hi  

It is better to use a URL that contains you username. Sourcetree relies on Git to andle authorization. Git does that by using the Git Credential Manager, GCM, that is bundled with Git for Windows.  

Git alone only has the ability to ask for a password when run from the command line, the GCM provides the popup GUI dialogs that allow git processes triggered by Sourcetree to interactively prompt the user for credentials.  

The GCM stores its credentials in the Windows Credential Manager, also referred to the Vault, you can access this through Windows Settings. The GCM creates/uses entries prefixed by 'git:'.  

If you use a URL without a username, e.g. *<https://bitbucket.org/username/myrepo>* , then the GCM will store credentials against *git:<https://bitbucket.org>* . This means anytime Git/GCM need to find credentials for use against bitbucket it will find and use these credentials. This works fine unitl you are using more than one account to access bitbucket. When that happens, and you are using URLs without usernames, Git/GCM will keep finding the current credentials and trying to use them, if they are correct for the repo you are trying to access they will work, if they are wrong Git/GCM will delete them, prompt you for the correct ones and then store the new ones. If you switch between repos and accounts this process will repeat endlessly.

If you use URL that **do** include usernames then the credentials are stored keys against, *git:https://username@bitbucket.org* , so each time you switch repos and accounts/usernames and you are using URLs with names Git/GCM will find the exact match.  

<br />

As for Askpass.exe that should be installed at *C:\\Users\\gshah\\AppData\\Local\\SourceTree\\app-2.4.7\\tools*. It is part of the Sourcetree install. Askpass.exe is a last chance fallback for authentication it should only appear if the GCM failed to get credentials it can use.


author: Gibran Shah
body: Hi Michael, thanks for the detailed feedback. I managed to solve the problem. The credentials prompt would always come up 3 times. What I didn't recognize at first was that on the third time, my username was auto-filled. This made me wonder: if it's recognizing my username on the third try, maybe it will also recognize my password. So I entered my password on the third try and presto! SourceTree has now cached my credentials and I'm able to connect to my repository automatically with my username in the url.


author: bella brown
body: Hello -- I'm also encountering this issue when trying to connect to github when using sourcetree. Do I need to use a URL with my username in it? If so, what's the format that I should use?

![sourcetree connect error.png](https://community.atlassian.com/t5/image/serverpage/image-id/142264iCBFB2237B7BA3299/image-size/large?v=v2&px=999 "sourcetree connect error.png")


author: minnsey
body: Hi   

It looks like you are using an older version are you able to update to the latest build form <https://sourcetreeapp.com> ?