DEV Community

Warner Bell
Warner Bell

Posted on

3

πŸ” How to Generate a GitHub Personal Access Token (PAT)

Follow these steps to create a GitHub Personal Access Token (PAT) to use for authentication with Git or other tools:

1. πŸ”‘ Log in to GitHub:

  • Go to GitHub and log in to your account.

2. βš™οΈ Access Developer Settings:

  • In the upper-right corner of any GitHub page, click your profile picture.
  • Select Settings from the dropdown.
  • Scroll down and, on the left sidebar, click Developer settings.

3. πŸ›  Generate a Personal Access Token:

  • In Developer settings, select Personal access tokens from the sidebar.
  • Click on Tokens (classic) and then click Generate new token.
  • Generate New Token (Classic)
  • Give the token a descriptive name, such as "Git CLI Token", so you can remember why you created it.

4. πŸ” Select Scopes and Permissions:

  • Choose the scopes or permissions to grant this token. For full access to repositories (push, pull, etc.), select the repo scope.
  • You may also want to choose workflow for GitHub Actions or admin:repo_hook for repository webhooks.
  • If you only need specific permissions, select the minimum necessary scopes for better security.

5. ⚑ Generate the Token:

  • After selecting your desired scopes, click Generate token at the bottom of the page.

6. πŸ“‹ Copy the Token:

  • Important: Once the token is generated, copy it immediately. You won't be able to view the token again after you leave the page.

7. πŸ›‘ Store the Token Safely:

  • Save the token in a secure location, like a password manager.
  • Use this token instead of your password when performing operations like pushing or pulling from a GitHub repository.

πŸ§‘β€πŸ’» Using the Token with Git:

When prompted for a username and password during Git operations, use:

  • Username: Your GitHub username.
  • Password: Paste your newly generated PAT.

Example during git push or git pull:


shell
Username: your-github-username
Password: your-access-token
Enter fullscreen mode Exit fullscreen mode

Speedy emails, satisfied customers

Postmark Image

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay