GitHub Token的使用
问题
本地项目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 xxx
解决方案
获取Token
settings->Developer settings->Personal access tokens
之后复制生成的token,最好暂时先存到一个文件中,后面要用到。
对于本地之前拉取的项目
通过命令修改关联的url方式,然后重新push即可。
git remote set-url origin https://YourToken@github.com/YourUserName/YourRepositoryName.git/
(或打开本地仓库.git
下的config文件中的[remote “origin”] 直接进行修改)
ps:
- 获取关联的url的命令
git ls-remote --get-url origin
对于克隆的新项目
- 输入密码时输入token即可。