当我尝试使用git pull时,我在控制台上得到了这个错误:

remote:在2021年8月13日删除了对密码认证的支持。请改用个人访问令牌。 remote:请参阅https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/了解更多信息。 致命:无法访问“…”:请求的URL返回错误:403

这很奇怪,因为我只是在两周前按照文档在GitHub上创建了一个令牌。该代币将于2021年10月26日周二到期。为什么今天这个被删除了?


当前回答

Android Studio Arctic Fox解决方案(Windows 10)

我在Android Studio Arctic Fox(最新版本)中使用个人访问令牌进行了身份验证,但我仍然在2021年8月14日得到了这个错误:

remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.

我在github.com上生成了一个新的访问令牌,从Android Studio中删除了我的GitHub帐户,并再次使用新的访问令牌添加帐户。但是,它仍然显示出同样的错误。

我在Stack Overflow上阅读了其他解决方案,下载了GitHub CLI,并在Windows命令提示符中成功添加了我的GitHub帐户和访问令牌,并尝试从Android Studio再次推送存储库,同样失败。

然后,在本文之后,我在命令行中执行了以下操作:

cd <project-directory>
git remote set-url origin https://<TOKEN>@github.com/<user_name>/<repo_name>.git

我从Android Studio再次推送,它终于工作了!

其他回答

对于任何使用Sourcetree作为Git客户端的人,打开首选项→进入帐户选项卡→添加GitHub帐户→认证类型=基本→填写您的GitHub帐户和您创建的GitHub访问令牌作为密码→使用HTTPS协议→完成!

对于Ubuntu,请执行以下步骤

在https://github.com/settings/tokens上,生成一个令牌。 git推 用户名:user_github_username 密码:add_generated_token代替密码。

对于Mac,去创建你的令牌。你只能看到一次。复制并安全地存储它。

打开Terminal,执行:gh auth login

*gh可以通过Homebrew安装

回答问题。确保在被问到时选择HTTPS。

我以前在Linux上使用git拉密码。

如果是这种情况,您唯一需要做的就是使用令牌来代替密码。

通过转到个人访问令牌生成一个访问令牌。

这里有一个git拉的例子

git pull

Username for 'https://github.com': gitusername
Password for 'https://yourusername@github.com': //Then enter generated token

对于那些使用Sourcetree和现有存储库的用户,您必须像这样更新存储库URL https:// < your_token > @github.com/username/repo.git

这是从这个答案中提取出来的。