Sourcetree remote: Invalid username or password
Asked Answered
M

23

124

Im trying to push to github with sourcetree but get the following error:

git -c diff.mnemonicprefix=false -c core.quotepath=false push -v --tags origin live_version:live_version remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/myname/myrepo/' Pushing to https://github.com/myname/myrepo

Completed with errors, see above.

enter image description here However when I go to

tools > authentication > my github account

And click edit > refresh oauth token enter image description here A page opens and I get:

Authentication Successful

SourceTree has been successfully authenticated. You may now close this page.

It always worked but it suddenly stopped, i do not have two factor authentication. I tried deleting the account and adding it again to no avail. How can I get the connection working again so that I can push my project to github.

Sourcetree version 2.1.8.0

Matias answered 10/8, 2017 at 20:30 Comment(1)
It is 2019, version 4, still can't just normally switch accounts in Sourcetree to work with another GitHub accountBroadway
M
256

I found the answer here, it is a known bug for version 2.1.8+

The following steps fixed it for me:

Tools > Options > Git > Update Embedded Git

Also pushing with the command line works.

EDIT

Also adding @Latisha's answer:

1. Do the above.
2. Close Sourcetree
3. Delete AppData\Local\Atlassian\SourceTree\passwd 
4. Restart SourceTree
Matias answered 11/8, 2017 at 14:9 Comment(15)
Close 1. Update the embedded git 2. Delete AppData\Local\Atlassian\SourceTree\passwd 3. Restart SourceTreeAsshur
I had the same issue with Git 2.6.2. This answer also fixed it. Now on git 2.13.2.Antenna
On OSX Sourcetree > Preferences > Git > Use System Git.Dollie
All it took for me was the answer given, no need to delete a password, close, or restart.Hurst
Thanks guys, saved me. Wish I had looked here before assuming I had just forgotten my github password and doing a reset. I needed to delete the passwd file btw. So it is sometimes required.Anastomosis
That didn't work for me, but switching to system git did (on Windows)Impenitent
@Asshur The step 2 works for me! SourceTree seems stupid to save the wrong password and won't allow me to update it, so I keep getting "Invalid username and password" error... until I delete it and retype the correct one.Sisterhood
I had the same issue with sourcetree 2.4.8 and git version 2.11 "Tools > Options > Git > Update Embedded Git" was all I needed to do. no extra steps required. Thanks!Chickabiddy
I had to follow @GoranCh. advice to switch to System GIT on PC; updating embedded GIT was enough untill last weekTater
Deleting the app data solved it - was stacking up commits locally and couldn't push! Thanks!Parlin
Did both, after deleting the password file, it worked. ThanksEastwood
Worked ... after entering username and password 7 times!! Thanks!Constitutionalism
I pushed using the command line git, and it worked. Thank you.Erechtheus
@GoranCh. Thanks, this should be the answer rather than a commentKobold
Hands down to this trick. I followed the same exact steps and it worked!Wrench
A
68

I struggled with this a lot, what solved it for me on my Mac is:

  • Open finder, click Cmd + Shift + g
  • enter ~/Library/
  • Go to Application Support/SourceTree folder
  • delete userName@STAuth-bitbucket.org
  • Open KeyChain Access
  • search for sourctree
  • delete the 'login' item
  • clone your source from bitbucket
  • KeyChain will ask for you bitbucket pass
Angeliqueangelis answered 19/11, 2017 at 16:15 Comment(11)
This is a pain, why SourceTree is not addressing this for Mac for so many versions.Molecule
this helped thanks, and thanks to i realized what was the real problem - when the initial password dialog for bitbucket appeared i entered wrong password thinking it is a classical admin password for my mac. after your fix this dialog appread again and i entered correct password.Curium
This is still a problem in 2019 with Sourcetree 2.7.6 for Mac.Smut
This is still a problem in 2020 with Sourcetree 4.0.1 for Mac.Weinhardt
This is still a problem in 2021 with Sourcetree 4.02 for Mac.Willyt
This should be accepted answer for all mac users! The only thing that worked for me was this, after I switched from password to two-factor authentication.Buoyage
This is the only thing that worked for me after enabling two-factor authEne
What do you mean by "clone your source from bitbucket"?Piggish
This worked for me in 2021 with sourcetree version 4.1.3(239). thanksHeadachy
This is still a problem in 2022 with Sourcetree 4.1.6 for Mac.Enrique
This is still a problem in 2022 with Sourcetree 4.2.0 for Mac.Manzoni
M
8

I faced this issue when i updated Embedded Git. Solved it by removing passwd file. you can find it here. then restart source tree.

AppData\Local\Atlassian\SourceTree\passwd

Merow answered 16/10, 2018 at 9:36 Comment(1)
Had the issue where only one of my repos would get this error, but it worked from the command line. Deleting the passwd file fixed it.Ransom
C
8

For OSX following by steps below

Go to: Preferences -> Advance -> Choose the account in table you want to remove -> Click to remove enter image description here

Crowded answered 14/5, 2020 at 16:55 Comment(0)
S
5

This worked for me on Mac

  1. Goto Preferences -> Git
  2. Use System Git
Swatter answered 10/1, 2021 at 19:32 Comment(0)
C
4

I had the same problem for Sourcetree 2.10, but with the above solution not working.

Reverting to version 2.0 solved it.

Sourcetree download archive: (https://www.sourcetreeapp.com/download-archives)

Corrigan answered 15/8, 2017 at 7:17 Comment(3)
Yes! Reverting from 2.1 down to 2.0 SOLVES THIS! 2.1 will currently just keep telling you to change password and then flipping between two different errors as you change password and reauth every time. Probably wont be updating for a while after dealing with this bug for several days..Harmaning
problem still exists in 2.2.4.0?Mimetic
problem seems fixed in 2.3.1.0 if you update embedded Git (Tools/Git/Update Embedded Git) to Git version 2.14.1/LibGit2Sharp 0.24.0 + git-lfs v2.2.1 (I made no changes to AppData\Local files)Corrigan
N
3

I just solved this problem by using an access token. I use macbook, all answers above didn't work for me. Go to your github account, click your profile image on right top corner, then click:

Settings -> Developer settings -> Personal access tokens -> Generate new token

Paste this token into sourcetree popup window, required password area, instead of typing your account password. Github uses two step verification, so you need to use a token rather than account password. Good luck! Let me know if this works for you.

Nurserymaid answered 26/2, 2019 at 11:19 Comment(0)
N
2

I had the same problem , I Relogged In to the account solved this error for me.

Nicholasnichole answered 23/1, 2018 at 6:20 Comment(1)
Similarly - I deleted my Github account and added it back and the problem was solved.Strongroom
P
2
  1. Delete your saved account in tools\option dialog.
  2. Push or pull again, and SourceTree will ask you to input your login name and password.
Palaeozoology answered 28/6, 2019 at 3:28 Comment(0)
A
1

If you do have two-factor authentication enabled in GitHub you might have gotten here as well. In that case follow AlonR's answer (for Mac - worked for me) or Sven's answer (for Windows - untested) and then follow the instructions here to make it work.

  • Currently the GitHub token page is here.
Amos answered 17/2, 2019 at 17:23 Comment(0)
T
1

For Mac user s:

Go to Preferences ▶︎ Advanced menu and delete the hostname that you want to reset.

After this, you can re-enter your username and password whenever needed

Tammeratammi answered 24/1, 2022 at 17:11 Comment(0)
U
0

I had the same problem and I fixed it by installing the latest version of git for windows

Ulphi answered 17/4, 2018 at 7:56 Comment(0)
T
0

For SourceTree 2.7.6 for macOS using embedded git I followed all the suggested answers but still had the same problem.

The solution for me was to turn off two factor authentication.

Obviously not ideal, but sometimes you just need to get your work done.

Trespass answered 27/6, 2018 at 8:26 Comment(1)
Didn't fix the issue for me.Fluorocarbon
T
0

On Windows try:

  1. Tools> Options> Authentication - delete from Git Saved Password your problem repo data (ex [email protected])
  2. Select tab with problem repo.
  3. Open terminal and make some git command (ex git pull origin) and you will be asked login and password. Input correct login and password. Login and password will be updated and all works again.
Tugman answered 10/7, 2018 at 9:17 Comment(0)
L
0

I typed the wrong username (email address) when pushing and what worked for me was:

Open KeyChain Access search for SourcTree delete the 'login' item

Then go to Sourcetree > Preferences > Advanced and delete the default usernames that includes the wrong email address.

Lots answered 16/5, 2019 at 13:17 Comment(0)
T
0

In my case, this happened on one of my two computers after I switched to OAuth on GitHub. The error message was referring to git-credential-manager.exe, which is located in AppData\Local\Atlassian\SourceTree\git_extras. I noticed that the version on my working machine is from 2018, whereas the one on the non-working machine is from 2017. Both run the newest version of SourceTree (3.0.17). This is what I did to get it to work:

  1. Uninstall SourceTree
  2. Since this did not remove AppData\Local\Atlassian\SourceTree, I deleted that entire directory manually
  3. Updated git to the newest version (neat: >git update-git-for-windows) - probably not necessary but a good idea anyway
  4. Re-installed SourceTree
  5. Added existing local repos
  6. Fetch - and finally, after entering username and password (twice, if memory serves), I get asked for the OAuth token. Yipee!

Surprisingly, AppData\Local\Atlassian\SourceTree\git_extras was created, but is now empty...

Transaction answered 12/4, 2020 at 12:37 Comment(0)
W
0

Sourcetree saves username in the below file. Change your username in this file and restart your sourcetree App

C:\Users\{USER}\AppData\Local\Atlassian\SourceTree\userhosts

Or Use your username in Clone URL. This will make sourcetree to request password for the new User

https://{user}@bitbucket.org
Wholism answered 18/5, 2021 at 12:42 Comment(0)
P
0

My setup

  • Windows 10
  • Sourcetree 3.4.5

What worked for me was a combination of some of the existing answers

  • Use system Git in Tools > Preferences.
  • Remove existing account credentials in Tools > Preferences.
  • Restart Sourcetree.
  • Do a complete credential check from command-line git with git push/pull, enter full credential once, and then go back to Sourcetree to retry.
Psilocybin answered 17/6, 2021 at 4:7 Comment(0)
M
0

It may be a simple case of expired Personal Access Token.

Mich answered 19/11, 2021 at 15:34 Comment(0)
T
0

I have the same error in Sourcetree app and after some changes (update git and Sourcetree app to latest version and delete AppData\Local\Atlassian\SourceTree\passwd) see this message when I want login.

remote: Bitbucket Cloud recently stopped supporting account passwords for Git authentication.

Good luck! Let me know if this works for you.

remote: See our community post for more details: https://atlassian.community/t5/x/x/ba-p/1948231

remote: App passwords are recommended for most use cases and can be created in your Personal settings:

remote: https://bitbucket.org/account/settings/app-passwords/

Create an app password

To create an app password:

  1. From your avatar in the bottom left, click Personal Settings.

  2. Click App passwords under Access management.

  3. Click Create app password.

  4. Give the app password a name related to the application that will use the password.

  5. Select the specific access and permissions you want this application password to have.

  6. Copy the generated password and either record or paste it into the application you want to give access. The password is only displayed this one time.

Add an app password to Sourcetree or another application

To add your app password to Sourcetree:

  1. Go to the tab where you'll add or edit your account details:

    • (Windows) Go to Tools > Options. From the Options dialog, select the Authentication tab.

    • (macOS) Go to Sourcetree > Preferences. From the dialog that options, select the Accounts tab.

  2. Click to Edit your account details or Add a new one.

  3. From Authentication or Auth Type, select Basic and enter your Username if it's not already there.

  4. Enter the app password you just created as your Password. If you're on Windows, you'll need to hit Refresh Password first.

  5. Click OK or Save to save your account details.

To add your app password to another application, see the application's documentation for how to apply the app password.

Traveled answered 16/3, 2022 at 15:57 Comment(0)
L
0

It was working for me in the Mac Terminal but not SourceTree 4.2.0. I changed my repository remote in SourceTree to include the path with the .git extension instead of the /src/master path and that worked for me. (To get the path, click on the clone button on the web page.)

Lapotin answered 11/10, 2022 at 21:13 Comment(0)
T
0

For me, I had to change Git Version to use System (by open Tool -> Options, then click on Git tab and scroll down a bit).

Tillo answered 15/2, 2023 at 7:48 Comment(0)
T
0

Solution for MAC OS:

1- Logout from your bitbucket using browser: https://bitbucket.company.com

2- Login again using: https://bitbucket.company.com/login?auth_fallback

3- Above link will ask for CAPTCHA validation and validate it.

4- Open KeyChain Access search for sourctree delete the 'login' item if any ( i did not find one) 5- Open KeyChain Access search for bitbucket delete the items entries found

6- Now clone your source from bitbucket and now KeyChain will ask for you bitbucket password.

Tilburg answered 26/5, 2023 at 21:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.