How to generate GitHub personal access token
If you ask me, GitHub’s removal of support for password authentication on August 13, 2021 was a bit of an overstep. But fortunately, it’s not overly difficult to create and use a GitHub personal access token instead. Just generate the personal access token in GitHub, and provide the token whenever Git prompts for your password.
Steps to create a GitHub personal access token
To create a personal access token in GitHub, follow these steps:
- Log into the online administrative console.
- Under your GitHub user profile (not the repository profile), click the “Settings” link.
- Scroll down and click the “Developer Settings” link.
- Click the GitHub “Personal access tokens” link.
- Click the “Generate new token” link and provide your password again if required.
- Provide a name for the GitHub personal access token in the “Note” field.
- Set the access token’s expiration timeout to “No expiration.”
- Click the checkbox for every permission scope to give your GitHub token full repository access.
- Click “Generate token.”
- Copy the GitHub Personal Access Token and use this as the password when you do a Git push.
How to use a GitHub personal access token?
The GitHub personal access token replaces your password. Any operation like a Git push that requires credentials prompts you for your username and password.
For the username, simply provide your GitHub account name.
For the password, provide your GitHub personal access token.
How to push with a GitHub access token?
The first time you perform a push to GitHub, you are prompted for your username and password. Simply provide your GitHub username and the access token and your files are uploaded to GitHub.
If you use Windows, your old credentials may be stored in the Windows Credentials Manager. Open this service, look for the web credential used by Git and delete it. Then perform a new push to GitHub.
The next time you perform a push with a GitHub personal access token, the new token will be stored by Windows. You won’t need to remember the value of the GitHub token on future Git push operations.