How to get and set a GitHub access token

GitHub’s repository access policy has been changed since August 2021

T Miyamoto
2 min readMar 26, 2022

GitHub’s repository access policy has been changed since August 2021, and so username-and-password-style login seemed to be abolished. As a result, when we try to push a branch by typing

git push -u origin,

we get the following error message:

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.

remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.

fatal: Authentication failed for ‘https://github.com/******/’

To deal with this, we first need to get an access token — we log on to the github page and click Settings.

Then, in the left area, we click <> Developer settings to see the page for access token. Then, click Personal access tokens tab, and press Generate new token button to get a new access token.

After obtaining our (new) access token, we set

git remote set-url origin https://<access token>.@github.com/<username>/<repository>.git

We can check if the access token is set or not by typing:

git remote -v

After checking it, we can now push a branch to our repo by typing:

git push -u origin <branch name>

--

--

Responses (1)