π How to Generate a GitHub Personal Access Token (PAT)
Warner Bell
Posted on October 27, 2024
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 oradmin: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
π πͺ π
π©
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.