git报错:remote: Support for password authentication was removed on August 13, 2021.


参考博客:https://blog.csdn.net/yjw123456/article/details/119696726

1、问题背景

在使用git提交代码时,发现有如下报错:

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.

意思是:意思是自从21年8月13后不再支持用户名密码的方式验证了,需要创建个人访问令牌(personal access token)

2、问题解决

① 点击头像 选择Settings


② 左侧栏中选择 Developer settings


③ 栏目中选择 Personal access tokens


④ 点击Generate new token


⑤ 填写选项

如果只是给自己使用的话,可以直接选择无限的有效期

另外,后面的一些权限,为了方便也可以全部勾选,再点击最后的Generate token生成令牌


⑥ 将生成的令牌拷贝下来,并且保存


⑦ 修改现有项目的url(注意在复制这条指令的时候,把汉字改成对应的内容之后,要把将括号删掉哦)

git remote set-url origin https://<你的令牌>@github.com/<你的git用户名>/<要修改的仓库名>.git