GitHub access tokens

How to generate an access token

Go to GitHub’s “New fine-grained personal access token” page, then set the following fields:

  • Token name
    Any name to identify the token in your device
  • Expiration
    If the device is from your company or shared, a closer expiration date will be better
  • Repository access
    Select “Only selected repositories” (Recommended) or “All repositories”.

Permissions

  1. Click on Add permissions or + and select “Contents”. (Usually the “Metadata” permission is automatically added.)
  2. Click outside, then in the list of permissions, for “Contents”, click on “Access: Read-only” dropdown and select “Read and write” option.

Click on Generate Token, confirm the information is correct and click on Generate Token again.

How to replace the expired token in your repo

If your token expired, generate a new token and run this command:

git remote set-url origin https://<token>@github.com/<username>/<repo>