Almin's Blog

Setting up Personal Access Token with GIT / Github

☕️ 2 min read

So Github requires now a new way to Authenticate yourself to execute github actions. (More info can be found on Github Blog )

Essentially you can not use your Basic Authentication anymore as in your Github username and password for executing git actions. So here I’m to offer an alternative. Not SSH alternative, since I’m too lazy to set that up on every machine, I will show a quick and easy way to never need to enter credentials without the need to use SSH keys.

Getting a PAT

  • First of, we need to generate a PAT (Personal Access Token). To do that we head over to our github profile and Right click on your profile image:

    Profile menu
  • Next, go to Settings > Developer Settings > Personal Access Token and we will arrive at this screen:

    Personal access token
  • Now we go to Generate New Token and we will be greeted with this view where we select scopes:

    Select scopes
  • For our case we just need to select the Repo scope:

    Selected scopes
  • We set a note and an Expiration (if you want to) and click Generate token.. and thats it, we now have a PAT, copy it and save in a text file for reference.

Setting up the PAT Authentication

Now, what we have to do is to do a git pull or git push in the repository we have where we will get the git prompt to enter the username and password. However, we will cancel this and instead we will write

git config --global credential.helper cache

This will save our next prompt for username and password (in our case our PAT) and we will not need to enter it again. So after execting this command we just git pull / push and the prompt should appear again. Enter our github username and our PAT as password and this is it. Until the the token expires we have our credentials set.

Hopefully this guide was helpfull!

If you want more small tips and cool links you can always subscribe to my Newsletter