12

github启用 personal access token后,历史项目如何进行认证变更

 3 years ago
source link: https://segmentfault.com/a/1190000040418898
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

github启用 personal access token后,历史项目如何进行认证变更

按照github的官方说法,github于2020年11月13日起逐步的推行使用token认证代替原来的用户名密码认证,该项工作于2021年年中左右推行完毕。所以一些历史上我们使用用户名+密码拉取的github仓库在进行git pull \ push \ fetch等操作时,会报如下错误:

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-3... for more information.

要解决这个问题,首先我们要参考官方文档来设置一个 token ,设置 token 的方法可参考官方文档

解决方法如下:
一、删除系统记往的密码
不同的系统删除系统记的密码不同,macos参考官方帮助文档进行删除即可。
如果运气好的话,再次执行git pull等操作时,便提示我们输入用户名、密码,此时密码输入我们在前面设置的 token 即可。
如果运行不好,请继续阅读。

二、配置git 的全局的认证帮助器为空

 git config --local credential.helper ""

此时,在执行一些git操作时,则会提示我们输入用户名密码,此时密码输入在 github 中的设置的 token 即可。

但这种方法有个弊端,那就是自此以后每次执行 git 命令都需要需要用户名密码,显示这是我们接受不了。

三、配置git项目
若不想每次都输入用户名密码,则可以在项目文件夹中执行git config --edit,然后将在远程仓库的位置上指定用户名与token.

[remote "origin"]
        url = https://githubusername:[email protected]/yunzhiclub/repositoryname
        fetch = +refs/heads/*:refs/remotes/origin/*




说起来有点意思,按官方文档的操作,并不能清空bash 中 git命令记录了用户名、密码的行为。所以最终没有办法,只能是将用户名、token写到了 git项目配置中。

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK