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

How do I connect to my Git repo using a Personal Access Token

justlikeUNIBLAB
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 17, 2021

Hi

I have a git repo that I am accessing via SourceTree. I now need to access it via a Personal Access Token instead of via a password, due to changes that GitHub has implemented.

I have successfully generated a PAT, but I cannot figure out how to access my repo using my PAT from SourceTree.

I have searched google and stackoverflow and the sourcetree documentation and have not been able to find an answer that works for me. Perhaps I haven't found the right page, or perhaps my setup is in a weird state.

When I try to push to my repo, I currently get this —

git --no-optional-locks -c color.branch=false -c color.diff=false -c color.status=false -c diff.mnemonicprefix=false -c core.quotepath=false -c credential.helper=sourcetree push -v --tags origin refs/heads/style4:refs/heads/style4
Pushing to https://github.com/justlikeUNIBLAB/whysaurus
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: unable to access 'https://github.com/justlikeUNIBLAB/whysaurus/': The requested URL returned error: 403
Completed with errors, see above

 

Thank you,

Josh

1 answer

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

5 votes
AdmiralHomes August 17, 2021

I was looking for hours to find a guide until I found this:

https://stackoverflow.com/questions/68191968/source-tree-fix-for-git-password-authentication-is-temporarily-disabled-as-part 

you apparently have to write your username and authentication token in front of the repository URL as such:

https://<USERNAME>:<TOKEN>@<GIT_URL>.git

it feels weird to me putting the access token in clear text in this way, but neither using the PAT as password or using OAuth works. So please update me if you found a better way! ^^

Rizqi Fauzul Fitria
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 18, 2021

but this way can't run for my case, could you give me an example for the URL?

AdmiralHomes August 18, 2021

instead of the usual "https://github.com/yourusername/yourrepository.git", you just put

"https://yourusername:yourtoken@github.com/yourusername/yourrepository.git" and you're good to go. Should be pretty much self-explanatory with the article on stackoverflow though.

Like crollsurf likes this
justlikeUNIBLAB
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
August 19, 2021

Thanks so much! When I try this solution SourceTree throws a pop-up that gave me pause, pasted below. Is the message in this pop-up not actually a concern, or is there a better  solution?

Screen Shot 2021-08-19 at 12.02.43 PM.png

AdmiralHomes September 13, 2021

With SourceTree, I didn't find a different solution. If you're too concerned or in an open network, I would suggest to switch to the GitHub desktop app, which runs with an internal authentication.

TAGS
AUG Leaders

Atlassian Community Events