我使用用户名密码来推送我的代码。它工作了几个月,但突然我不能这样做,并得到这个错误:

Username for 'https://github.com': shreyas-jadhav
Password for 'https://shreyas-jadhav@github.com':
remote: Password authentication is temporarily disabled as part of a brownout. Please use a personal access token instead.
remote: Please see https://github.blog/2020-07-30-token-authentication-requirements-for-api-and-git-operations/ for more information.

请注意,这个链接没有任何帮助。即使使用生成的令牌也无济于事。

主持人注:这是GitHub计划的一部分,很快将是永久的服务变化


当前回答

GitHub正在取消用户名密码认证

其他人提到的另一种方法:

您可以安装和配置GitHub CLI。使用OAuth进行设置要好得多。不需要手动从密钥链中删除凭据。

在macOS上使用Homebrew (brew),安装甚至更简单:

执行命令brew install gh,执行如下命令:

您想登录哪个账户?GitHub.com,选择GitHub Git操作的首选协议是什么?选择HTTPS 用你的GitHub凭证验证Git ?选择是的 您想如何验证GitHub CLI?选择“使用web浏览器登录” 复制终端-> B7C1-8E67中显示的代码 按Enter键在浏览器中打开github.com 使用浏览器验证身份

完成了。

开始像往常一样使用Git命令。

其他回答

GitHub已禁用密码认证,且不再支持密码认证。创建并使用个人访问令牌(PAT)而不是密码。

以下步骤:

Remove GitHub stored credentials from the keychain. (For example, using "Keychain Access" on Mac, or "Credential Manager" on Windows) Generate access-token from GitHub Settings → Developer Settings → Personal access tokens → Generate new token Save the token - as it will be available there for once only Run command git fetch (or git push, if fetching doesn't require permissions) If on Windows, you must run this from PowerShell, not the command prompt (CMD). The command prompt consistently fails with the remote: Password authentication is temporarily disabled message, despite identical inputs. It will ask for your user name and password. If it does not ask you for your username and password, you must change your Git remote URL to contain your username: https://USERNAME@github.com/repo-owner/repo-name.git (see approach 2 for instructions on changing remote URL) Use the access token instead of the password when it asks for a password (you will have to enter it twice)

或者第二种方法:

从GitHub生成访问令牌: 设置→开发人员设置→个人访问令牌→生成新的令牌 在本地更新origin的URL: git remote set-url origin https://<token>@<git_url>.git 拉一次:git拉https://<token>@<git_url>.git

我今天下午遇到了这个问题,并通过将参考文献3中所述的GitHub密码替换为参考文献2中生成的令牌来解决这个问题。

参考文献1:参见API和Git操作的令牌身份验证要求。不再支持该密码。 参考文献2:因此,您应该在本教程中生成一个令牌,并使用它代替您的密码作为凭据。 参考资料3:如果没有提示您输入用户名和密码,则您的凭据可能缓存在您的计算机上。您可以在Keychain中更新凭据,用本教程中描述的令牌替换旧密码。

GitHub正在取消用户名密码认证

其他人提到的另一种方法:

您可以安装和配置GitHub CLI。使用OAuth进行设置要好得多。不需要手动从密钥链中删除凭据。

在macOS上使用Homebrew (brew),安装甚至更简单:

执行命令brew install gh,执行如下命令:

您想登录哪个账户?GitHub.com,选择GitHub Git操作的首选协议是什么?选择HTTPS 用你的GitHub凭证验证Git ?选择是的 您想如何验证GitHub CLI?选择“使用web浏览器登录” 复制终端-> B7C1-8E67中显示的代码 按Enter键在浏览器中打开github.com 使用浏览器验证身份

完成了。

开始像往常一样使用Git命令。

你所要做的就是使用一个生成的令牌而不是传统的密码:

使用密码的旧方法:

git clone https://github.com/username/repo.git

Username: your_username
Password: your_password

使用令牌的新方法:

git clone https://github.com/username/repo.git

Username: your_username
Password: your_token

步骤1:从GitHub生成API令牌

阅读本文档创建个人访问令牌:配置双因素身份验证

步骤2:用新生成的令牌替换之前缓存的密码

正如这里回答的,你必须修改你的本地GitHub登录凭证缓存在你的电脑: 从Git中删除凭证

创建个人访问令牌 在Visual Studio Code命令行中: Git配置——全局凭据。辅助(YOUR_TOKEN)