Github配置仓库Git环境

将代码提交到Github时,突然报错:

1
2
3
4
➜  RemoteWorking git:(master) git 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.
fatal: Authentication failed for 'https://github.com/yaronzz/xxxxx.git/'

这是由于Github提高了仓库的安全性,访问仓库时需要提供令牌token

生成token

  1. 访问Personal Access Tokens (github.com) ,点击生成新token

image-20220225095049918

  1. 配置名称、有效期、访问权限

image-20220225095152285

  1. 点击复制token,此token只能查看一次,最好自己保存到其他地方

image-20220225095350129

使用token

重新设置git的远程地址:

1
git remote set-url origin https://<你的token>@github.com/<你的github名称>/<你的仓库名>.git