Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Adding a github personal access token to sourcetree

Joel C_ Miller July 21, 2021

I've recently used sourcetree for the first time in over a year.  I'm getting a message from github that I need to use a personal access token.  I've got to github and created the token.

 

But...  I cannot figure out how to update sourcetree to use the token.  What steps do I take (I'm on windows if that matters)?

8 answers

5 votes
Galih AAAd October 10, 2021

I just found the answerr in case you haven't. Im also using windows.

  1. you can generate the Personal Access Token first from github
  2. You can remove your github credential first from 'Credential Manager' as mentioned here: https://github.community/t/how-to-start-using-a-personal-access-token-to-authenticate-git-on-windows/163304/2
  3. you can try to do like push so sourcetree will ask for your credential and you can enter your id and PAT in the password part
  4. BUT. if there's no cred confirmation window prompted, you can manually remove the id from the 'passwd' file as mentioned here: https://stackoverflow.com/questions/68191968/source-tree-fix-for-git-password-authentication-is-temporarily-disabled-as-part#:~:text=In%20Windows%2C%20go%20to%20C,you%20for%20your%20credentials%20again.
  5. delete the id line in that file then save
  6. try to push again in your sourcetree, but this time it'll definitely ask for you credential
  7. add your id & PAT
  8. DONE! <3 hope this helps.
Brian Boyd May 8, 2022

Makes me want to learn git via CLI, instead.

Like Mikkelet likes this
Aniket Khaire December 29, 2022

Thanks a lot, been stuck for hours! 

When your token is expired-
Deleting passwd file works for me.
Even if you Authenticate the source tree with newly new Token correctly, SourceTree wont work 
Following are the item I performed:
-Delete passwd file
-Generate PAN 
   -Requires Authorization from an Organisation if added any (Check Configure SSO)
-Go to repo in Performed any Remote fetching operation like push/fetch
-Mention your Username and PAN as your password

This should work! 

3 votes
Duane Roelands November 25, 2021

Spent three hours trying to make SourceTree work with GitHub.  Scouring message boards, endless Googling, trying half a dozen solutions and none of them working.

Downloaded GItKraken and I was back to work five minutes later.

tamirad1 December 20, 2021

I installed GitHub Desktop and it was working out of the box.

Not clear how a company like Atlassian keeps SourceTree so hard to operate for a basic feature.

Why should I search forums on how to solve a basic issue like connecting to GitHub using a token? Atlassian should update SourceTree to have a clear way to integrate with GitHub using an access token.

Amanda Giles December 21, 2021

I believe it's that SourceTree lets you control which version of Git you are using. So, for me, I was using an older version before Git even implemented tokens. So the app allows for flexibility, but this also brings complexity when the underlying features change. 

Like majew7 likes this
Brian Boyd May 8, 2022

And their attitude really is: if you don't like it, then don't use it.

It's really a love/hate relationship that they maintain with their user base.

Brian Boyd May 8, 2022

Thanks for the GItKraken  recommendation!

I wasted four hours tonight wrestling with installing SourceTree on a new machine only to find out that it's solution RE: PAT's is insecure (it actually shows the PAT!).

This was the final straw. Goodbye SourceTree.

2 votes
majew7 December 23, 2021

I had a similar issue on my Mac (Big Sur):

  • Yes; Git with personal access tokens setup via Mac's Keychain Access worked fine at command-line (e.g. iTerm2).
  • No; SourceTree would throw errors about missing my personal access token for simple operations like pulling.

 

My Solution

Configure SourceTree to use "System Git".  Just select "Use System Git" to select the Git version which is installed on your system.   

Using Embedded Git or System Git in SourceTree 

Thus, the issue seems to have gone away in SourceTree, since my System Git is properly reading from my Mac's Keychain Access, and SourceTree is no longer using the Embedded Git.

1 vote
nwbowensby September 2, 2022

I have been struggling with this for over a year.  I've been getting by with OAuth but it seems like that solution is lasting a shorter and shorter amount of time.  In fact I re-upped my OAuth yesterday and it asked me again today.  I thought I'd try again to get the personal access token but still no luck.  

I've generated and regenerated my PAT.  I have cleared out my authentication for github in source tree and try adding it back with basic authentication.  When I do this it usually tells me "Failed to check login for user [myusername] user/emails was not found".  This happens whether I use my username or my email address.  I tried resigning in to github and my username/email works there.  I see others have gotten it to work so I'm not sure the difference.

nwbowensby September 2, 2022

I'm not really sure what the full list of required steps to fix my problem was but I finally fixed it.  The things I did this morning was the following:

  1. Removed all authentications for github in source tree
  2. Installed the latest version of git
  3. Switched to the system git instead of embedded in source tree
  4. Opened the file "c:\users\[user]\AppData\Local\Atlassian\SourceTree\password" and removed the github entry there
  5. Restarted source tree
  6. Did a push

I want to make it clear that when I tried step 4 previously but it just made source tree act weird so I put it back.  Not sure if the other steps helped with that or not.  The other odd thing with step 4 is that the username was not the right username for github.  After I restarted source tree and hit push the prompt was different this time than before. It actually gave me an option to just use my PAT (didn't ask for user name...maybe because I had an active github sessions) and it worked.

0 votes
Brian Boyd September 6, 2022

After suffering this problem (and several others), I switched over to GitHub Desktop and am not looking back. 

0 votes
howieyoung August 17, 2021

There are many different issues you might face.

We have tried to dig into each of them and resolve them all finally.

This article could be helpful for you:
https://howieyoung.medium.com/suffering-from-the-latest-403-error-from-github-on-sourcetree-e04a844efd35

0 votes
Amanda Giles July 26, 2021

According to this article - https://confluence.atlassian.com/sourcetreekb/two-factor-authentication-2fa-with-github-in-sourcetree-402033499.html - you can create your personal access token and then use that in lieu of your password within SourceTree.

Joel C_ Miller July 26, 2021

The question is how do I tell SourceTree to use that token?  I cannot find an option to change the password SourceTree uses when it accesses github.

Amanda Giles July 26, 2021

In my version, it's Tools > Options > Authentication (tab) > github.com. That sets it globally.

If you need to change it per repository, you can choose Repository > Repository Settings > Advanced > User Information

Like Rob Howe - IWP likes this
Elizabeth Curtis August 13, 2021

I tried that and still can't get in.

Like Lee Swee Ling likes this
Lee Swee Ling January 13, 2022

Follow this solution working for me! Thanks a lot for sharing!

Like Amanda Giles likes this
0 votes
Deepak Sinha July 21, 2021

same issue..

jboada July 25, 2021

mmm I have the same issue too

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events