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

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

这招对我很管用:

生成个人访问令牌(不要忘记复制令牌) 打开您的钥匙链访问(Mac)或凭据管理器(Windows)。 在KeyChain access /Credential Manager中使用新的个人访问令牌更新GitHub密码 最后一步:克隆Git(确保将存储库克隆到正确的目录位置) Git克隆https://github.com/username/repo.git 用户名:your_username 密码:your_token

在我的情况下,它没有提示我的用户名和密码,因为它已经在钥匙串访问更新。

还有一个非常简洁的脚本,有助于将HTTPS克隆的Git存储库转换为ssh协议,而无需删除和克隆Git存储库:

将HTTPS GitHub克隆转换为使用SSH

适用于macOS, Windows和Linux

解决方案1

删除现有的存储库(如果当前有任何更改,请对其进行备份): Mv my-repo my-repo.backup 创建SSH密钥并将其添加到GitHub(参见GitHub文档) 为SSH克隆存储库:git克隆git@github.com:group/repo-name.git

方案二(推荐方案)

Git远程删除原点 您必须添加一个访问令牌(请参阅GitHub文档以生成令牌) Git远程添加origin https://<token>@<git_url>.git Git拉https://<token>@<git_url>.git

使用Visual Studio代码

删除你的GitHub访问:

git credential-osxkeychain erase
⏎  host=github.com
⏎  protocol=https

不是推就是拉 它将提示您一个模态对话框。单击“允许”并按照流程操作。

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

使用密码的旧方法:

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中删除凭证