【突发】解决remote: Support for password authentication was removed on August 13, 2021. Please use a perso
原创
©著作权归作者所有:来自51CTO博客作者愤怒的可乐的原创作品,请联系作者获取转载授权,否则将追究法律责任
引言
Github不能拉代码了?
今天我像往常那样更新一下Github代码,发现竟然报了下面的错误:
$ git pull
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: unable to access 'https:///<USERNAME>/<REPO>.git': The requested URL returned error: 403
意思是自从21年8月13后不再支持用户名密码的方式验证了,需要创建个人访问令牌(personal access token)。
解决
生成令牌
首先生成一个令牌,←链接是官网教程,也可以不点,直接看下文。
- 点击Settings

- 点击左侧的Developer settings

- 点击Personal access tokens(个人访问令牌)

- 点击Generate new token

- 设置token信息


- 点击Generate token生成令牌
- 得到生成的令牌

应用令牌
将生成的令牌拷贝下来(不要拷贝我的,拷贝你自己生成的!),记得保存,下次你就看不到了。
修改现有项目的url
git remote set-url origin https://<your_token>@/<USERNAME>/<REPO>.git
将<your_token>换成你自己得到的令牌。<USERNAME>是你自己github的用户名,<REPO>是你的项目名称,比如我的:
git remote set-url origin https://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@/nlp-greyfoss/typora_notes.git/
其实上面的报错中就有提示,不需要重新去找:
fatal: unable to access 'https:///<USERNAME>/<REPO>.git':
https://
/<USERNAME>/<REPO>.git
然后再执行git pull,世界又恢复原样了。
船新版本
对于全新版本,克隆的时候也在前面加个令牌就好了。
git clone https://<TOKEN>@/<user_name>/<repo_name>.git