今天新建了一个GitHub远程仓库,在本地代码push的时候报错:
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.

百度了一番,才明白现在推送代码需要带token
生成token的方式很简单:
在GitHub点击自己的头像,找到Settings

然后找到Developer settings

然后选择Personal access tokens

点击Generate new token

填一个note(描述信息),设置一个token过期时间,如果是推送代码勾选repo ,最后 点击“Generate token”,就会生成一个token,记录一下我们这个token,一会再次push代码的时候要用到

然后修改remote 地址,我是先把以前的远程地址删掉,然后再添加带token的地址
git remote remove origin(删掉现在的远程地址)
git remote -v (查看一下是否删除成功,没有输出任何内容就是删除成功)
git remote add origin https://token_startabcabcabc_token_end@github.com/sober-orange/study.git
(把你的token放在你的远程地址里面,“token_startabcabcabc_token_end”是你刚才生成的token,“https://@github.com/sober-orange/study.git”是你的GitHub远程地址)
然后再次push你的代码就可以了。
网友评论