17

im new to github and im using sourcetree for my git gui, ive been using it for a few days, but now lately im getting an error that says

remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/Nosthertus/nodejs_Chat.git/'

also when i tried to make another registration to github returns with error

authorization failed

maybe its because i made a two-factor security, i thought on making a shh-key with github, but does not fix the problem, there has to be a way to make my gui connect to my github account without the login access, how do i fix this?

0

9 Answers 9

34

If your password recently changed, select the repository, go to Tools --> options, go to Authentication tab and delete the stored password. This will make the system request a new password when you next try to connect.

On OSX: go to SourceTree --> Preferences --> Network and delete the default username there.

1
  • 1
    As far as im concerned, this should be the accepted answer to this question. Only when i read this, i realized how to reset the git password for a selected repository. Feb 17, 2017 at 9:22
10

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.

Source

5

its because i made a two-factor security

Following the Heartbleed bug, GitHub has reset all browser sessions that were active prior to the vulnerability being addressed on our servers.

Check if your PAT (Personnal Access token) is still valid in the Applications section of your GitHub Account.

Note that ssh keys have no effect on an https url like https://github.com/Nosthertus/nodejs_Chat.git

Would you need to use your ssh key, you should at least change the origin url:

git remote set-url origin [email protected]:Nosthertus/nodejs_Chat.git
0
3

Make sure that your credentials are OK (please check before in the GitHub website), then, in my case the answer was the following.

1) Delete the "psswd" file without opening Sourcetree:

C:\Users\USER\AppData\Local\Atlassian\SourceTree\passwd

2) After doing that, try to re-enter the application and specify your credentials again.

3) If the previous steps doesn't work, in my case, it was using an incorrect username, so you can edit the "userhosts" file located in the same folder and change to the proper username that you're using:

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

By doing this, I was able to push again. Hope it helps!

3
  1. In GitHub, on the top-right corner, click on the profile icon and select Settings.

enter image description here

  1. From the left-side menu, towards the bottom, select Developer Settings.

enter image description here

  1. Select the Personal access tokens option.

enter image description here

  1. now finally click on the Generate New Token button/link.

enter image description here

This will prompt you to enter your password. After entering your password, you will see a page to add new token.

enter image description here

1. Depending on the requirement, you can set an expiration for your token, or you can set "No expiration" from the dropdown.
2. For scopes, agin, upon your requirement, check-mark the necessary ones.
3. Finally hit `Generate token`.

This will generate a token. Keep a copy of the token.

1. In source tree, from the top-right, select `Settings`. 
2. In the pop-up, select remote to add your remote path for repository.
3. Copy the repository path(the .git path) from GitHub into the `URL/ path`, but now you need to add the access-token like following-

enter image description here

if the repository path is https://github.com/username/repository_name.git, you need to add the access token in-between https:// and github.com/username/repository.git with @ like-

https://[email protected]/username/repository.git

hit ok and you are good to go now.

1
  • all correct beside the username is wrong. it is not username in the url, it is the owner github account name. So basically you can be a part of a repository belongs to under another github account
    – Emil
    Jan 23 at 0:27
2

I am using 2FA and I was able to resolve authentication issues by creating an API key as described in the linked document:

https://confluence.atlassian.com/sourcetreekb/two-factor-authentication-2fa-with-github-in-sourcetree-402033499.html

Note: after generating the key, copy it and replace your password with the API key in SourceTree (Tools/Options/Authentication tab --> select item in Saved Passwords and click edit...)

I hope this helps.

1
  • This worked well for me compared to the other answers. Using the personal token as the password alongside my github email. May 26, 2017 at 19:14
2

I'm using Personal access tokens (GitHub -> settings -> Personal access tokens) and I needed to regenerate the token and then remove the username from SourceTree (SourceTree -> preferences -> network ->remove) then pull and you will be prompt to enter user name and password Use the token you generated

0
0

SOURCE TREE

Tools > Options > Authentication > Edit (Edit Password)

0

If all above is not work, you can try (it works for me)

  • In command, open: %LOCALAPPDATA%\Atlassian\SourceTree\passwd
  • Delete your usename and password, then try to fetch,push...in source tree, it will ask you input usename password again
  • Input new username/password. Sometime, the password is a token, (e.g. when you working with azure devopt, depend to your setting you can get the token to input to password field enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.