Gangmax Blog

GitHub Personal Access Token

According to the post from GitHub, “Beginning August 13, 2021, we will no longer accept account passwords when authenticating Git operations on GitHub.com.”

So I need to use token authentication instead. Here is how. From here.

  1. Go to “github.com -> Settings -> Developer settings -> Personal access tokens”, create a token first. For normal usage, you just need to check the “repo” related scope items when creating the token. Let’s say the token value is “ThIsiStHeToKeNcOnTeNt”.

  2. Go to your local git repo and run the following command:

1
2
3
4
5
6
7
8
# Remove the existing tracked repository.
git remote remove origin
# Add the tracked repository with token info.
git remote add origin https://oauth2:ThIsiStHeToKeNcOnTeNt@github.com/user/project.git
# 3. Set upstream branch.
git branch --set-upstream-to=origin/main main
# Or:
git push -u origin main
  1. Now you should be able to do your git operations, without typing the password anymore.

Comments