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

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仪表板生成您的PAT(个人访问令牌)。

Step 1: Log in to your GitHub account. Step 2: In the upper-right corner of any page, click your profile photo, then click Settings. Step 3: In the left sidebar, click Developer settings. Step 4: In the left sidebar, click Personal access tokens. Step 5: Click Generate new token. Step 6: Give your token a descriptive name. Step 7: Select the scopes, or permissions. You'd like to grant this token. To use your token to access repositories from the command line, select repo. Step 8: Click Generate token.

复制您的令牌到一个安全的位置,因为一旦您离开该页面,您将无法检索它,除非您创建一个新的。

其他回答

之前接受的Kusal Shrestha的答案可以完成这项工作,但它并不安全,因为我们将令牌存储在纯文本中。

在我看来,将它存储在钥匙链中是更好的方法。

对于Visual Studio Code,请阅读crg的回答。

Windows:

你可以试试下面的@Venryx评论,但我还没有测试过。


Mac:

我现在才面对这个问题

按照建议,我按照这个URL进入开发设置并生成了一个令牌。

然后我进入我的Mac的钥匙链访问:

我删除了(所有)行的GitHub

现在我去终端输入了虚拟代码

git push

终端要求我输入我的邮箱和密码。

我输入了我的电子邮件,对于密码,我输入了我之前生成的令牌。

然后它又开始工作了。

下面的步骤对我来说非常有效

以下步骤:

从GitHub生成一个访问令牌,设置→开发者设置→个人访问令牌→生成新的令牌 保存令牌-因为它只在那里可用一次 在系统中搜索。git-credential文件 在该文件中,在用户名之后使用访问令牌而不是密码。

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

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