SourceTree keeps asking for Github password
Asked Answered
K

28

82

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

Kerman answered 20/7, 2016 at 19:15 Comment(2)
S
118

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.
  2. Click on the Generate new token button.
  3. Name the token something descriptive.
  4. Select which scopes you wish to grant this token.
  5. Click the Generate token button.
  6. 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
Sole answered 21/7, 2016 at 21:14 Comment(8)
Personal Access Tokens is at Settings / Developer settingsFixed
"... and use it as a password in your hosted repositories". How?Ammonic
@Alex75, I'm not sure where the confusion is. Use the token instead of your password in SourceTree.Sole
All this steps are done automatically by SourceTree when you clone a repo (A new token is automatically created and used). I still have this noisy GitHub login popup. So I want tot try your "manual" solution. In SourceTree, mrenu Repository -> Advanced -> User information tab. There is a checkbox for "Use global user settings" or you have to pass "Full name" abd "Email address". Where can I set the token ? This problem exists only for the private Git repository of my company (2 factor authentication enabled), I never had problems with my personal GitHub account at home.Ammonic
How can SourceTree generate a token for you if it can't log into GitHub? (If you're using 2FA and you want to log into GitHub you must either enter your password, be prompted for the 2FA code, and provide a valid one, or provide a personal access token. Did SourceTree ask you for a 2FA code?)Sole
for me, this part did the trick: git config --global credential.helper osxkeychainLogographic
I've been struggling with this for more than a year and never got to solving this problem. "git config --global credential.helper osxkeychain". This works like a charm!Windflower
One more step that I had to perform was - using ssh -T [email protected] this prompted - ` The authenticity of host 'github.com' can't be established. RSA key fingerprint is _________. Are you sure you want to continue connecting (yes/no)? ` pressing yes after this made it work.Cressler
S
25

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à !

Schmidt answered 27/3, 2019 at 14:35 Comment(7)
That is for https URLs. To my knowledge, an SSH URL does not involve a credential helper.Vain
This helps! I';m using SSH too.Beautician
I think it's good to mention, this solution stores your credentials unencrypted: git-scm.com/docs/git-credential-storeCanoewood
this works after our enterprise stuffed AD serviceDoorman
Only works for command line. Sourcetree keeps asking for the password EVERY TIME! I'm going crazy!Gastric
This was the only solution that worked for me, after I tried with all of the above. It works with MacOS Ventura 13.0.1 & SourceTree 4.2.0Ferriage
Support for password authentication was removed on August 13, 2021. remote: Please see docs.github.com/en/get-started/getting-started-with-git/… for information on currently recommended modes of authentication.Insular
S
14

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

Stanleigh answered 9/6, 2020 at 16:30 Comment(2)
did this, still has problem, keep asking password again and againRodl
Did this, but still keep asking for password :(Maccarone
B
12

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.

Beehive answered 2/8, 2018 at 10:9 Comment(3)
Thanks, this solution works for me. The key step was to update git credential manager here --> github.com/Microsoft/Git-Credential-Manager-for-Windows/…Absentminded
I just ran into this today with SourceTree Mac Client. GitHub just shutdown password authentication today. Pulled my hair out getting SourceTree to work. GitHub Desktop worked fine and Fork worked fine. SourceTree no go, until I finally thought to try switching SourceTree to use system git. @Beehive post helped confirm it. Thx.Booma
This was by far the simplest solution that worked for me.Cockfight
T
8

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 :)

Turro answered 27/2, 2018 at 16:59 Comment(2)
Thank you ( ^_^) ! I have dropped all SouceTree keys and retry to pull, after entering password for 1st time it doesn't ask me for that anymore. It's much better than every time enter a password 2 times in a row even you've configured SSH keysEncampment
I thank You for that! Atlassian should definitely fix the issue with the saved passwords. They do not seam to understand, that passwords change! As well as I would hereby also recommend better explanations which passwords must be entered! There is no list for that in SourceTree and one must go and find that @£$€ themselves from users>yourname>local>Atlassian>password.Mahla
S
4

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.

Squilgee answered 12/5, 2017 at 16:28 Comment(0)
I
4

For windows user

change SSH Client from Putty/Plink to OpenSSH

in Tools -> Option -> SSHClient

enter image description here

Intentional answered 21/9, 2021 at 5:38 Comment(0)
W
4

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

Walcoff answered 28/12, 2021 at 21:47 Comment(1)
This worked in MacSingleness
H
4

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

Hoff answered 4/1, 2022 at 8:12 Comment(0)
K
3

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
Kiarakibble answered 25/5, 2021 at 9:6 Comment(2)
"Edit" or "Add" - same deal - if the account is new to sourcetree, it's just as simple, since you just login via browser to do same, and it instantly recognises that. See my answer (written before I saw yours).Teodoor
Right, it just gets confusing if the OAuth token expires (which it does periodically). It's not obvious that that is what happened because the login screen appears and just fails to login.Kiarakibble
P
2

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
Podgy answered 3/7, 2018 at 4:9 Comment(0)
L
2

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.
Lecherous answered 23/2, 2019 at 17:58 Comment(0)
P
2

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

Peking answered 14/9, 2019 at 19:7 Comment(1)
very good! i love youLatrena
T
2

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 :-)

Troupe answered 27/1, 2021 at 11:58 Comment(0)
V
1

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.

Vain answered 20/7, 2016 at 19:42 Comment(0)
A
1

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!

Amidships answered 26/3, 2018 at 20:17 Comment(0)
P
1

Mac: This solution works for me. After clone code successfully, you open terminal and run this code

git config --global credential.helper osxkeychain
Padding answered 16/10, 2019 at 2:6 Comment(0)
T
1

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

Tormentor answered 3/3, 2020 at 7:33 Comment(0)
T
1

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.
Teodoor answered 2/6, 2021 at 21:0 Comment(0)
R
1

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 been the 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

Rozanna answered 25/2, 2022 at 18:45 Comment(0)
L
1

In my case I needed to put my ssh password instead of my personal access token. Then it worked.

Lapboard answered 20/9, 2022 at 21:25 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewHyperactive
A
0

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.

Argos answered 25/4, 2017 at 15:21 Comment(0)
C
0

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.

Correctitude answered 25/4, 2018 at 3:47 Comment(0)
D
0

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.

Doty answered 14/4, 2021 at 11:19 Comment(0)
M
0

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

Mentalist answered 22/4, 2022 at 13:19 Comment(0)
E
0

For 2023: Upgrade SourceTree & Use Token

I tried the above answers and nothing worked for me.

Once I upgraded SourceTree (version at least 4.2.5), I was able to get this to work via adding a new Account.

Github

First, create a developer access token in Github.

  1. Github account > Settings > Developer Settings > Generate New Token
  2. Give it the access you want. (Ability to admin Org will help with list of repos in Sourcetree)
  3. Generate token
  4. Key step: If your org uses 2FA, you'll need to click to authorize this token once it's generated.

SourceTree

Now, in your SourceTree, add a new Github (Token) Account:

  1. Accounts > Add New Account
  2. Select GitHub
  3. Select Personal Access Token
  4. Here you need the Developer Token you've set up. Paste it in here.
  5. Protocol: HTTPS
  6. Add a repository at this point.

You should be good to go.

Erasion answered 25/10, 2023 at 17:56 Comment(1)
I tried same in my macOS but it keep asking me for password in popup. if i do pull/push via terminal then everything is working fineSock
B
0

I had the same issue, Tried multiple ways to fix it, but finally it solved just by logout and login again.

Boltzmann answered 23/6 at 4:43 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Achlorhydria
H
-2

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

Harrier answered 15/5, 2019 at 6:32 Comment(1)
Can you explain that further? How does "going" solve the problem of a tool asking for a password?Revivify

© 2022 - 2024 — McMap. All rights reserved.