How to start using a personal access token to authenticate git on windows

I have created a personal access token to replace the use of password using git over hhtps. From the help docs I’ve read on the subject, I can’t find straight forward information about how to start using the PAT and replace my current form of authentcaition which is a password. When I perform git operations, I am not being prompted for a password so I guess the windows credential manager is managing the password authentication for me. So what do I need to do to actually make the switch? And what ever I do to make the switch, is this a universal change accross all git accesss, or will I have to do something on a per repo basis. For ssh, you would use ssh-add. But what do you do for a PAT using https?

This article (Creating a personal access token - GitHub Docs) doesn’t tell you this information and it probably should; well apart from clong the repo, but I dont need to clone it because I’m currently working on it!

2 Likes

If you are still using an existing cached password for you login you will need to remove it, the below will help, hopefully :slight_smile:

Launch ‘Credential Manager’ on your Windows device.
Switch to tab Windows Credentials (it default displayed tab Web Credentials on my device).
A list of locally cached credentials are then shown
Find an entry starting something like git:htttps//login@github.com (this will be an exist cached entry for your username/password. You can safely delete this by selecting the entry and clicking on .Remove’.

You will then be prompted for credentials on you next git action requiring authentication
when prompted for username ener login
when prompted for password enter YOUR-PAT you created earlier.

Good luck

9 Likes

Hi
Works on Linux-kde too :slight_smile:
Thanks

1 Like

After not using Github for a few months I tried pushing something yesterday and got a message to say that in future, password access is being abandoned and I’ll need to use something called a Personal Access Token. I’ve read the instructions but to be honest, it seems like a lot of hard work for no real benefit. Maybe Github should think about retaining password access for the simpler accounts (e,g, free accounts).

2 Likes

@johne53,
if you run a recent Git version and you would rather not go down the creating a personal token explicitly route,
There is an option to authenticate using [Sign in with browser] , which may be a more familiar approach and less effort for many.

Thanks bryneh - I’m using TortoiseGit here (on Windows) and it seems to have an option for sites which use a putty key, rather than a password. Is that the same thing as a personal access token?

@johne53, putty is often used for accessing remote unix server command lines SSH.
So it could be an SSH key, you can access git using SSH instead of https, the remote URL you specify has a different format. You have to add the public key part of your SSH key to you GitHub acount.
Connecting to GitHub with SSH - GitHub Docs.

I cannot comment on TortoiseGit specifically (as I do nit use it), but your product help/docs will hopefully clarify

Thanks again - so just to check I’m understanding this… if someone usually pushes stuff to Github using a local git client, such as TortoiseGit:-

  1. Pushing stuff the conventional way (by using a password and user name) won’t work any more in future
  2. Pushing stuff can be done by obtaining a Personal Access Token (assuming the local client supports it ?)
  3. Pushing stuff by using a Putty key will also work - except that I’d need to access Github via an SSH address, rather than https

@johne53
Point 1. is fully explained and by when.GitHub Blog 2020-12-15 - token authentication requirements for git operations
Point 2. Yes
Point 3. Yes, you can use SSH for Git operations as detailed here connecting-to-github-with-ssh

In summary you can use SSH, or a created personal access token, or for client that supports a web auth flow [Sig in with browser] that gets a OAuth token for you in the background.

I suggest you just try it.
If you then hit a problem raise a new Topic on this community forum, explaining you problem, what you are using and steps to recreate,
Good luck

I just did this in Tortoise Git. When it asks for credentials via the normal password dialogue I had to cancel the first dialogue, then press Ctrl-C as instructed, to get the CLI password dialogue. Enter my username in the first box offered, then the PAT as the ‘password’ in the second box, and I’m in!

Having done that, I can go back into GitHub without being asked for credentials.

2 Likes

Here’s how I set it up with Tortoise Git in Windows, to use the github personal access token:

Once you create a Personal Access Token in github (see: Creating a personal access token - GitHub Docs), go to your TortoiseGit settings for your repository, then go to the local .git/config… It should open in Notepad.

After that, edit the URL to the repository, in the format of github username:access_token@rest/of/the/url.git, like so:

Worked for me. Was able to push code with no problems. It did not ask for my credentials.

4 Likes

Thank you. This worked for me.

Many thanks! I’ve never seen the Credentials Manager before, glad to have learned about it today!

Thanks, it was hard to find at my old version of Tortoise, but worked as a charm

Would have saved me a lot of searching if Github had made it clear what to do after getting the PAT. Cannot understand why this is not mentioned anywhere I could find. Thanks swampopus for the clear and simple instructions

1 Like

Maybe I missed it here but I can’t see how to do this with my Mac. I have a PAT but don’t know how to get it set up so I can use Github. I have a personal access token but don’t know how to make it work on github.