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

warnerbell

Warner Bell

Posted on October 27, 2024

πŸ” 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
πŸ’– πŸ’ͺ πŸ™… 🚩
warnerbell
Warner Bell

Posted on October 27, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related