'SourceTree keeps asking for Github password
My organization is switching from Bitbucket to Github for project management. Today, I was trying to transfer our most recent project from Bitbucket to Github, by using SourceTree. I added a second remote repository to the project (using the URL of the destination repository on Github), brought everything up to date, and then attempted to push the code to the repository. A box popped up, asking for the password to my Github account. I entered in my (correct) password, and clicked 'OK', and the dialog box popped up again. I entered in my password (correctly) again, and it did the same thing.
My username is correctly identified, my password is correct, and I tried updating SourceTree because I had heard that it was an issue with a previous version. The problem persists.
I am using SourceTree 2.3.1
Solution 1:[1]
If you are using two-factor authentication with GitHub you will need to create a personal access token and use it with SourceTree:
To work with GitHub's two-factor authentication in SourceTree you can simply use your access token instead of your password. The steps to do this are as follows:
- Go to your Personal Access Tokens settings in GitHub.
- Click on the Generate new token button.
- Name the token something descriptive.
- Select which scopes you wish to grant this token.
- Click the Generate token button.
- Copy the token and use it as a password in your hosted repositories.
You can find more information about this on GitHub's help here.
Mac Users: If your SourceTree keeps on asking for the password, go to the Terminal and type this:
git config --global credential.helper osxkeychain
Solution 2:[2]
I am using a SSH key, but SourceTree was asking me a password every time.
Found on the community of Atlassian, this solution worked for me:
- Open the terminal, get into your project directory
- Type
git config credential.helper store
- Type
git pull
- Input username/password (if asked)
Voilà !
Solution 3:[3]
Follow to @Chris answer in case you've enabled 2FA, to use Personal Access Token
in SourceTree, you need to add your acc with this token in SourceTree > Preferences with following information:
- Auth Type: Basic
- Username: {your-github-account}
- Password: {your-personal-access-token}
- Protocol: HTTPS
After that, you are able to clone your Github repo.
Solution 4:[4]
A solution worked for me given by Andrew Magill, Copied from Source : link
The problem is that SourceTree's embedded Git client comes with git-credential-manager v1.12, which no longer works with Github since they disabled TLS 1.1 on their site. You need to get git-credential-manager v1.14. Easiest way to do that is to install a current copy of the Git client separately, and then switch SourceTree over to use that ("system git") instead of its embedded client. Alternatively, you can update git-credential-manager in your embedded client by replacing its files with the newest version from Microsoft.
Solution 5:[5]
I had a similar thing after an update; I tried re-adding my bitbucket credentials, changing the protocols, etc. with no luck, until...
I opened my keychain and searched for bitbucket (probably the same for github, just search for github instead) under the Passwords category.
I found that I had multiple Access Keys for my user, so I closed my repository, deleted all the keys of "application password" Kind, opened the SourceTree preferences > Accounts > removed my account and re-added it (login as usual - I used Basic with HTTPS).
Keychain asks for permission to save the password, which I said yes and now I only see one key of the kind "application password".
I opened my repository from the repo browser and hey presto, no more password popups!
This bugged me for a whole week! If this helped you, you can do a little dance with me now :)
Solution 6:[6]
open terminal and clone your repo. repository url must have your usedid, For ex:
$ git clone https://<username>@github.com/<userId>/<reponame>.git
$ git clone https://[email protected]/mak123/<reponame>.git
Then drag and drop the cloned folder into the sourceTree window.You can also do by clicking "+New Repository" button and from the menu by selecting "Add Existing Local Repository". It may ask for password again but this time it will get added to your keychain.
Solution 7:[7]
In my case, the Sourcetree login screen repeatedly showed when pushing to GitHub. Logging in from that screen failed. I finally determined it was due to an expired OAuth token, which is trivial to fix.
- Navigate to the GitHub account config screen: Tools > Options > Authentication
- Click your GitHub account and then click edit
- On the Edit Hosting Account dialog click the Refresh OAuth Token button
Solution 8:[8]
Here is what worked for me.
I tried almost all the solutions mentioned here and on the web a lot of times. I gave up multiple times before and was using it this way for more than a year I think. Finally, I was able to solve this annoying issue.
- As suggested by user "AEQ" in his answer, I deleted all the passwords related to GitHub from my Keychain Access.
- Tried deleting and re-adding the Github account. But still, the problem persisted. (generated a personal access token from "https://github.com/settings/tokens" and use it as the password)
What made it work was Make sure to use HTTPS and not SSH when adding the new user account. If you have already added the account, just edit it. That's it.
Finally, It feels good.
Attaching screenshots for ease.
Solution 9:[9]
This is what I discovered (after searching for 'sourcetree' in my drive C:):
- Uninstall SourceTree
- Delete folder C:\Users[username]\AppData\Local\Atlassian\SourceTree
- Delete folder C:\Users[username]\AppData\Local\SourceTree
- Reinstall SourceTree
Solution 10:[10]
In addition to setting up the Personal Access Token on GitHub, and doing what A_01 states above, this may be helpful (it's how I finally got it working)
- I made sure had the latest version of Sourcetree
- I upgraded to the latest version of and used System Git (Tools -> Options -> Git)
- Upgraded to the latest Git Credential Manager for Windows (this was via an installer I downloaded and double-clicked, very easy)
- Ensured I was using OAuth for my GitHub account stored in Tools -> Options -> Authentication
- Made sure I checked off the box "Allow Sourcetree to manage my credentials using the Git Credential Manager" (this was important!!) on Tools -> Options -> Git
- Then when I triggered the GitHub dialog (via pushing a new branch, just an example), I logged in there (this is where it used to fail).
- I next got the 2 factor auth dialog, and the code was sent to my phone as expected. I was able to enter the code from my phone into this dialog.
Solution 11:[11]
Solution 12:[12]
If you are not using GitHub 2FA, another reason for asking you your password is:
Your GitHub repo url is an ssh one, not an https one.
Since git does not find your ssh keys (or your ssh key is not registered to your GitHub account), it fails back to account/password mechanism.
If you are using 2FA (and an https url), then you need a personal token as a password.
Solution 13:[13]
SourceTree version 2.4.8.0
The problem for me seemed to be the order of setup between SourceTree and GitHub. I setup SourceTree first and just clicked all the "setup later" options.
An easy fix - Uninstall and re-install SourceTree. The non-obvious bit was needing to delete the actual program files manually.
From any "SourceTree.exe" shortcut, open file location. Mine forked at "C:\Users\myusername\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Atlassian" where the shortcut pointed to another shortcut.
Open that shortcut's file location. I eventually ended up at "C:\Users\myusername\AppData\Local\SourceTree". Delete the whole "SourceTree" folder. Go up one level to "...\Local" and delete the "Atlassian" folder as well.
Now uninstall SourceTree. Make sure your GitHub is setup the way you desire (for me, I also created and saved an SSH key that I used for SourceTree setup). Re-install SourceTree using all the correct credentials, point to the right repository and such.
After all this, SourceTree asked for my GitHub credentials twice, with two different dialog boxes, then stopped and worked! No more endless loop. Good luck!
Solution 14:[14]
For future references, I solved this problem by changing the GIT system used in Sourcetree, from Embedded
to System
.
How to change the git system:
1. Find the Options submenu (located under Tools menu) and click on it to view the Options popup
2. On the Options setting popup, find the Git tab, then click on it to view the Git setting
3. Find Git version setting, then check the version used in it. In my case, I changed it to system because previously I'm using Git bash cmd, and it looks like that the git embedded in Sourcetree clashes with each other.
4. Restart Sourcetree
Solution 15:[15]
Just another stupid reason: you may have changed credentials on your laptop, but there is another development PC running but not frequently used, that has SourceTree started and uses the old credentials frequently to poll status.
Sounds stupid, but took me some time to solve :-)
Solution 16:[16]
Since this question is specifically about SourceTree and Github, the answer in 2021 is simple. Quoting bcr:
Ensured I was using OAuth for my GitHub account stored in Tools -> Options -> Authentication
- Go there. Select
Add
(new account). - Select OAuth.
- Click
Refresh OAuth Token
. A browser page will open (github.com) requesting renewal of your token. - Login to accept. SourceTree will immediately respond by acknowledging the token provided by github.com.
Solution 17:[17]
I finally was able to solve this after months of no luck. On a Mac :
- Open 'Keychain Access' on a Mac by using Launchpad or Spotlight Search
- Narrow down your search by selecting "login" under Keychains and "Passwords" under the Category (both filters on the left side of the window)
- In the top right hand corner of the window, do a search for "git"
- You'll likely see a keychain there. I right-clicked and deleted the one entry I had.
- Go into sourcetree and try to do a pull/fetch/anything. You'll be prompted for a password. This should re-initiate your password with Sourcetree. To double check this, go into your keychain and repeat steps 3 & 4. Click on the keychain and look at the access control tab. SourcetreeLogin should be listed as always having access now.
Solution 18:[18]
Really struggled with this on Mac, couldn't get it to work with SSH. Ended up following this guide which worked: https://www.youtube.com/watch?v=otRHRPnHDeI.
There were a couple things which could have been the cause, it may not have bee nthe SSH itself. For instance, Oauth apparently doesn't work on SourceTree despite nothing appearing wrong immediately when using it. Making sure you use a Personal Access Token and not your real password among others.
A good rule of thumb is, if after connecting your account it only shows your public repos, it's already broken. https://github.com/settings/tokens
Solution 19:[19]
In my case, this was happening with a submodule that had defaulted to https even though the main project was using ssh. I fixed it by changing the submodule's repo path in SourceTree's Repository Settings to use the ssh path instead of https.
Solution 20:[20]
If you are using "Username & Password" authentication,you can try to change to use SSH keys for the authentication.
I have met this kind of situation when I commit to GitLab everytime.When I changed the way of authentication:SSH keys,the problem has been solved.
Solution 21:[21]
In my case, I cloned the repo using HTTPS based url. Then I configured my githib
account with 2-factor authentication using SSH key. So whenever I was pulling/pushing changes, it was showing me dialog to provide my password.
I fixed it by enabling SSH access by right clicking on project repo-menu on SourceTree.
Solution 22:[22]
Mac: This solution works for me. After clone code successfully, you open terminal and run this code
git config --global credential.helper osxkeychain
Solution 23:[23]
In my case, the password that Sourcetree was asking for was for the ssh private key password. If I remove the password from the ssh key, this prompt doesn't come up.
However since I wanted the password to be there, I kept investigating why it wasn't accepting my ssh key password.
Turns out there is a wrinkle. If you have multiple ssh private keys which have different passwords, Sourcetree will give you a password prompt for each password.
Think of it this way - if you have a fresh shell in your system, and you just started ssh-agent up, and ran ssh-add
, what are the password prompts that you get? For every such password prompt, Sourcetree will give you this dialog box. In fact, if you add passwords to the dialog in the same order as you would in the shell to an ssh-add
, this would work. In fact, I am guessing Sourcetree is doing exactly the same in the background.
So my final solution was 1) keep the passwords on the ssh keys 2) make all these passwords the same. So now Sourcetree will give me a single password prompt, and entering the ssh private key password will work.
Solution 24:[24]
The easiest way is to create an app password and use that password. Here you can see how you can create an app password on Bitbucket:
Solution 25:[25]
Go to Sourctree -> Tools -> Options -> Git Select
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow