问题记录
使用git clone下载代码报错
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/zhoulei519/MyTest.git/'
具体报错,2021年8月13日后不支持密码登录,需要使用token验证
官网说明:官方说明
解决方案
1、找到GitHub的个人Settings页面:(图一)
2、找到Developer settings (左侧菜单栏,最下方)(图二)
3、选择个人访问令牌Personal access tokens,然后选中生成令牌Generate new token
第一个选项是新出的,这个也是可以选的
4、选好后输入密码,进入设置页面,设置token的特性,比如:标题,有效期,token权限等等
5、设置完成后,生成令牌
一定要把令牌复制下来保存好,因为不能二次查看
6、再次使用git clone,不过在输入密码的时候输入我们刚刚生成的令牌就可以正常下载了
设置令牌
可以把token直接添加远程仓库链接中,这样就可以避免同一个仓库每次提交代码都要输入token了:
git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git
- <your_token>:换成你自己得到的token
- <USERNAME>:是你自己github的用户名
- <REPO>:是你的仓库名称
设置完成,以后更新代码就不用每次都输入账户和密码了