SourceTree keeps asking for Github password

GitGithubBitbucketAtlassian SourcetreeSourcetree

Git Problem Overview


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

Git Solutions


Solution 1 - Git

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:

> 1. Go to your Personal Access Tokens settings in GitHub.

  1. Click on the Generate new token button.
  2. Name the token something descriptive.
  3. Select which scopes you wish to grant this token.
  4. Click the Generate token button.
  5. 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 - Git

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:

  1. Open the terminal, get into your project directory
  2. Type git config credential.helper store
  3. Type git pull
  4. Input username/password (if asked)

VoilĂ  !

Solution 3 - Git

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.

enter image description here

Solution 4 - Git

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 - Git

I had a similar thing after an update; I tried re-adding my bitbucket credentials, changing the protocols, etc. with no luck, until...

  1. I opened my keychain and searched for bitbucket (probably the same for github, just search for github instead) under the Passwords category.

  2. 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).

  3. 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 - Git

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 - Git

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.

  1. Navigate to the GitHub account config screen: Tools > Options > Authentication
  2. Click your GitHub account and then click edit
  3. On the Edit Hosting Account dialog click the Refresh OAuth Token button

Solution 8 - Git

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.

  1. As suggested by user "AEQ" in his answer, I deleted all the passwords related to GitHub from my Keychain Access.
  2. 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.

Screenshot

Solution 9 - Git

This is what I discovered (after searching for 'sourcetree' in my drive C:):

  1. Uninstall SourceTree
  2. Delete folder C:\Users[username]\AppData\Local\Atlassian\SourceTree
  3. Delete folder C:\Users[username]\AppData\Local\SourceTree
  4. Reinstall SourceTree

Solution 10 - Git

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 - Git

For windows user

> change SSH Client from Putty/Plink to OpenSSH

in Tools -> Option -> SSHClient

enter image description here

Solution 12 - Git

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 - Git

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 - Git

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 - Git

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 - Git

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 - Git

I finally was able to solve this after months of no luck. On a Mac :

  1. Open 'Keychain Access' on a Mac by using Launchpad or Spotlight Search
  2. Narrow down your search by selecting "login" under Keychains and "Passwords" under the Category (both filters on the left side of the window)
  3. In the top right hand corner of the window, do a search for "git"
  4. You'll likely see a keychain there. I right-clicked and deleted the one entry I had.
  5. 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.

Keychain Example

Solution 18 - Git

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 - Git

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 - Git

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 - Git

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.

enter image description here

Solution 22 - Git

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 - Git

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 - Git

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:

https://docs.snyk.io/tutorials/getting-started/atlassian-integrations/atlassian-bitbucket-app-password

Solution 25 - Git

Go to Sourctree -> Tools -> Options -> Git Select

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionAbigail FoxView Question on Stackoverflow
Solution 1 - GitChrisView Answer on Stackoverflow
Solution 2 - GitMarcView Answer on Stackoverflow
Solution 3 - Gitnahung89View Answer on Stackoverflow
Solution 4 - GitA_01View Answer on Stackoverflow
Solution 5 - GitAEQView Answer on Stackoverflow
Solution 6 - GitPrabhu.SomasundaramView Answer on Stackoverflow
Solution 7 - GitGeckView Answer on Stackoverflow
Solution 8 - Git2xSamuraiView Answer on Stackoverflow
Solution 9 - GitJeremiah FlagaView Answer on Stackoverflow
Solution 10 - GitbcrView Answer on Stackoverflow
Solution 11 - GitMeghs DhameliyaView Answer on Stackoverflow
Solution 12 - GitVonCView Answer on Stackoverflow
Solution 13 - GitJoshView Answer on Stackoverflow
Solution 14 - GitartikandriView Answer on Stackoverflow
Solution 15 - GitStiefelView Answer on Stackoverflow
Solution 16 - GitEngineerView Answer on Stackoverflow
Solution 17 - Gitbondra76View Answer on Stackoverflow
Solution 18 - GitTheoView Answer on Stackoverflow
Solution 19 - GitSwindlerView Answer on Stackoverflow
Solution 20 - GitifeegooView Answer on Stackoverflow
Solution 21 - GitSauvik DoluiView Answer on Stackoverflow
Solution 22 - GitAnh DuyView Answer on Stackoverflow
Solution 23 - GitSandip BhattacharyaView Answer on Stackoverflow
Solution 24 - GitArash MASView Answer on Stackoverflow
Solution 25 - GitOmkarView Answer on Stackoverflow