现象
github提交代码时报错: remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
大概意思就是你原先的密码凭证从2021年8月13日开始就不能用了,必须使用个人访问令牌(personal access token),就是把你的密码替换成token!
如何生成自己的token
- 个人设置页,Setting
- Developer setting
- 选择个人访问令牌
Personal access tokens,然后选中生成令牌Generate new token
4.设置token的有效期,访问权限等
选择要授予此令牌token的范围或权限。
- 要使用
token从命令行访问仓库,请选择repo。 - 要使用
token从命令行删除仓库,请选择delete_repo - 其他根据需要进行勾选
- 生成令牌
Generate token
注意: 保存好生成的token,刷新页面时会消失。
- 用生成的token作为git登录时的密码粘贴到
输入密码的位置,然后push代码。 也可以 把token直接添加远程仓库链接中,这样就可以避免同一个仓库每次提交代码都要输入token了:git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git
<your_token>:换成你自己得到的token<USERNAME>:是你自己github的用户名<REPO>:是你的仓库名称
常见问题
- 如果push等操作没有出现
输入密码选项,输入如下命令,再次执行操作输入用户名密码
git config --system --unset credential.helper