通过https方式clone/push github远程仓库时报错
报错情况
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 "..." : The requested URL returned error: 403
问题分析
从2021年起,通过https方式克隆/推送github仓库代码时,必须使用访问令牌
访问令牌
两种令牌的比较
github可以配置两种令牌,特点如下表(详情见参考文档链接):
| personal access tokens (classic) | Fine-grained personal access token |
|---|---|
创建访问令牌(这里以personal access tokens (classic)为例)
如图点击菜单栏中的Settings按钮
如图点击菜单栏中的Developer settings按钮
如图点击菜单栏中的Tokens (classic)按钮
点击创建令牌按钮后,如图填写令牌配置信息:
- Note:填该令牌的备注信息
- Expiration:可以设置无限期(No expiration)
- Select scopes:至少要勾选repo,这里规定了使用该令牌访问服务端的权限
复制令牌内容(记得保留,退出该页面后要重新申请才能获取该令牌!!!)