Generating a Personal Access Token in GitHub

Using a Personal Access Token or PAT is the standard way to authenticate when using the command line or the API. GitHub now offers two types: Fine-grained (recommended) and Classic.

2. Choose Your Token Type

On the left sidebar, click Personal access tokens. You will see two options:

Option B: Tokens (classic)

Best for general use or older tools that don’t support fine-grained permissions.

  1. Click Tokens (classic) -> Generate new token (classic).

  2. Note: Enter a description (e.g., “Home PC Access”).

  3. Expiration: Select a duration.

  4. Scopes: For general command-line use, check the repo box (this grants full control of private and public repositories).

  5. Click Generate token.


3. Save Your Token

[!IMPORTANT] Copy the token immediately. GitHub will never show it to you again. If you lose it, you’ll have to delete it and create a new one.

How to use it

When your terminal (or VS Code) asks for your GitHub password, paste the token instead of your actual password.

Pro-tip: If you find yourself pasting this constantly, you can save it globally using: git config --global credential.helper store