How to change the authentication of historical projects after enabling personal access token on github

myskies
中文

According to github's official statement, github will gradually implement the use of token authentication to replace the original user name and password authentication from November 13, 2020, and this work will be completed around the middle of 2021. Therefore, some github repositories that we used to pull by username + password in history will report the following error when performing git pull \ push \ fetch and other operations:

remote: Password authentication is temporarily disabled as part of a brownout. Please use a personal access token instead.
remote: Please see https://github.blog/2020-07-30-token-authentication-requirements-for-api-and-git-operations/ for more information.

To solve this problem, we must first refer to the official document to set a token. For the method of setting the token, refer to the official document .

The solution is as follows:
1. Delete the password recorded by the system
Different systems delete different passwords in the system. For macos, refer to the help document to delete it.
If you are lucky, git pull such as 0610131b6cd4e7 again, we will be prompted to enter the user name and password. At this time, the password can be entered in the token we set above.
If it doesn't work well, please continue reading.

2. Configure the global authentication helper of git to be empty

 git config --local credential.helper ""

At this point, when performing some git operations, we will be prompted to enter the username and password. At this time, the password can be entered in the token set in github.

But this method has a drawback, that is, since then, every time a git command is executed, a user name and password are required, showing that this is not acceptable to us.

Three, configure git project
If you do not want to enter the user name and password every time, you can execute git config --edit in the project folder, and then specify the user name and token on the remote warehouse location.

[remote "origin"]
        url = https://githubusername:youtoken@github.com/yunzhiclub/repositoryname
        fetch = +refs/heads/*:refs/remotes/origin/*



It is a bit interesting to say, according to the operation of the official document, the git command in bash cannot be cleared to record the user name and password. So in the end, there is no way but to write the username and token into the git project configuration.

阅读 6.2k

河北工业大学梦云智软件开发团队
河北工业大学梦云智软件开发团队
2.5k 声望
199 粉丝
0 条评论
2.5k 声望
199 粉丝
宣传栏