主要问题
:
vscode的terminal上面推送代码到不同账号,要么重新登录vscode的账号,这样很麻烦,在ubuntu的terminal终端推送代码,需要输入用户名和密码,但是github使用authentication app鉴权后没法输入密码登录github了,在用git push的时候登录不上。
报错像下面这样
:
remote: Support for password authentication was removed on August 13, 2021. remote: Please
see https://docs.github.com/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls
for information on currently recommended modes of authentication. fatal: 'https://github.com/XXXX/X_code.git/' 鉴权失败
解决方式
从2021年8月13日开始,GitHub不再支持使用密码进行身份验证。你需要使用个人访问令牌(PAT)或SSH密钥进行身份验证。
以下是如何创建和使用个人访问令牌的步骤:
- 登录到你的GitHub账户。
- 点击右上角的头像,然后选择"Settings"。
- 在左侧的菜单中,选择"Developer settings"。
- 在左侧的菜单中,选择"Personal access tokens"。
- 点击"Generate new token"。
- 在"Note"字段中输入一个描述,然后在"Expiration"字段中选择一个过期日期。
- 在"Select scopes"部分,选择你需要的权限,然后点击"Generate token"。
- 在下一页中,你将看到你的新令牌。复制这个令牌并保存好,因为你以后将无法再次查看它。
然后,当你在命令行中被要求输入GitHub的用户名和密码时,用户名仍然是你的GitHub用户名,但密码应该是你刚刚创建的个人访问令牌。
如果你使用的是VS Code的集成终端,你可能需要更新你的Git凭据存储以使用新的令牌。你可以在VS Code的设置中搜索"Git: Credential Helper"并选择一个合适的选项,或者你可以在终端中运行以下命令:
git config --global credential.helper store
然后,下次你被要求输入密码时,输入你的个人访问令牌,它将被保存并用于后续的身份验证。
获取token的页面:
git push