Reputation: 1691
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
Upvotes: 84
Views: 100703
Reputation: 1
I had the same issue, Tried multiple ways to fix it, but finally it solved just by logout and login again.
Upvotes: 0
Reputation: 4602
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.
authorize
this token once it's generated.SourceTree
Now, in your SourceTree, add a new Github (Token) Account:
GitHub
Personal Access Token
HTTPS
You should be good to go.
Upvotes: 2
Reputation: 11
In my case I needed to put my ssh password instead of my personal access token. Then it worked.
Upvotes: 1
Reputation: 45
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
Upvotes: 1
Reputation: 156
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:
Upvotes: 0
Reputation: 1319
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.
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.
Upvotes: 4
Reputation: 109
I finally was able to solve this after months of no luck. On a Mac :
Upvotes: 5
Reputation: 2454
For windows user
change SSH Client from Putty/Plink to OpenSSH
in Tools -> Option -> SSHClient
Upvotes: 4
Reputation: 8857
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
Add
(new account).Refresh OAuth Token
. A browser page will open (github.com) requesting renewal of your token.Upvotes: 1
Reputation: 41
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.
Upvotes: 4
Reputation: 1132
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.
Upvotes: 0
Reputation: 2793
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 :-)
Upvotes: 2
Reputation: 8105
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:
After that, you are able to clone your Github repo.
Upvotes: 14
Reputation: 179
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
Upvotes: 1
Reputation: 1183
Mac: This solution works for me. After clone code successfully, you open terminal and run this code
git config --global credential.helper osxkeychain
Upvotes: 1
Reputation: 5660
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.
Upvotes: 2
Reputation: 11359
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:
git config credential.helper store
git pull
Voilà !
Upvotes: 25
Reputation: 2073
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)
Upvotes: 2
Reputation: 1141
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.
Upvotes: 13
Reputation: 4789
This is what I discovered (after searching for 'sourcetree' in my drive C:):
Upvotes: 2
Reputation: 7292
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.
Upvotes: 0
Reputation: 11
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!
Upvotes: 1
Reputation: 1429
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 :)
Upvotes: 8
Reputation: 137108
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
Upvotes: 123
Reputation: 1390
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.
Upvotes: 4
Reputation: 810
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.
Upvotes: 0
Reputation: 1328182
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.
Upvotes: 1