Sourcetree remote: Invalid username or password

GitAuthenticationGithubAtlassian Sourcetree

Git Problem Overview


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

Git Solutions


Solution 1 - Git

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

Solution 2 - Git

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

Solution 3 - Git

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)

Solution 4 - Git

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

Solution 5 - Git

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

Solution 6 - Git

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.

Solution 7 - Git

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

Solution 8 - Git

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.

Solution 9 - Git

  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.

Solution 10 - Git

This worked for me on Mac

  1. Goto Preferences -> Git
  2. Use System Git

Solution 11 - Git

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

Solution 12 - Git

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.

Solution 13 - Git

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.

Solution 14 - Git

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.

Solution 15 - Git

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

Solution 16 - Git

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

Solution 17 - Git

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.

Solution 18 - Git

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

Solution 19 - Git

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

Solution 20 - Git

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.

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
QuestionSven van den BoogaartView Question on Stackoverflow
Solution 1 - GitSven van den BoogaartView Answer on Stackoverflow
Solution 2 - GitAlon RosenfeldView Answer on Stackoverflow
Solution 3 - Git2slothView Answer on Stackoverflow
Solution 4 - GitMohamed NagehView Answer on Stackoverflow
Solution 5 - GitDuy PhanView Answer on Stackoverflow
Solution 6 - GitMikeView Answer on Stackoverflow
Solution 7 - GitAbhishekView Answer on Stackoverflow
Solution 8 - GitMikeLView Answer on Stackoverflow
Solution 9 - GitbeibeituView Answer on Stackoverflow
Solution 10 - GitTushar VengurlekarView Answer on Stackoverflow
Solution 11 - Gitemanuel.vircaView Answer on Stackoverflow
Solution 12 - GitlewisView Answer on Stackoverflow
Solution 13 - Git0xA0View Answer on Stackoverflow
Solution 14 - Gituser909943View Answer on Stackoverflow
Solution 15 - GitJoergEwaldView Answer on Stackoverflow
Solution 16 - GitrobinrjoeView Answer on Stackoverflow
Solution 17 - GitkakyoView Answer on Stackoverflow
Solution 18 - GitMuhammad IrfanView Answer on Stackoverflow
Solution 19 - GitAshView Answer on Stackoverflow
Solution 20 - Gitsaeid mohammad hashemView Answer on Stackoverflow