N Kaushik

How to create Github personal access token or PAT

March 22, 2021

How to setup Github personal access token:

Github will stop supporting https with password starting from August, 13th 2021. Alternatively, Github is providing a new way to connect to your git repositories. It is called a personal access token or PAT. Creating a new PAT is easy and it is more easy to manage than ssh.

Most application supports PAT now. For example, on Android Studio or Github desktop, if you try to clone or push to an unknown account, it asks for PAT. Below image is on a Windows laptop while I am trying to push code to a new account:

github personal access token

How to create a personal access token in Github:

You can follow the below steps to create a personal access token or PAT in Github:

  1. Go to your Github account, click on your profile photo and click on settings.

  2. On left side, click on Developer settings.

developer settings click

  1. Click on Personal access token on the left bar.

personal access token

  1. It will show you the list of tokens already generated. Click on Generate new token to create a new token. You can give a name for the token. Also, you can select from a list of permissions to give for this token.

access token permission

  1. Click on Generate token to generate the token. For security reasons, this token is shown only for one time. If you refresh the page, it will be removed.

How to use it on command line:

PAT works only with https. We can use it instead of password. For example, if we are cloning a repository on https, we can enter the username as the github username and PAT as the password.

Also, note that personal access token is deleted automatically if it is not used for more than one year.


Subscribe to my Newsletter