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

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计划的一部分,很快将是永久的服务变化


当前回答

如果你使用的是HTTPS版本而不是SSH版本,那么这个错误将会出现,因为GitHub正在删除HTTPS方法来维护存储库。

生成一个SSH密钥,如果你还没有SSH -keygen,并继续按Enter直到结束 猫~ / . ssh / id_rsa。Pub -复制结果 访问https://github.com/settings/keys 单击“新建SSH密钥”,将密钥粘贴到文本框中。标题可以是任何你想要的 CD <到项目的目录> Git remote set-url origin git@github.com:<username-here>/<repository-name-here>.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)

这招对我很管用:

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

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

这里有一个简单的解决方案:

进入GitHub→设置→开发者设置→个人访问令牌。重新生成令牌并复制它。 在任何本地存储库上,当git推送时,输入您的用户名,密码是生成的令牌

无需为每个HTTPS Git操作手动输入令牌,您可以使用Git客户端缓存令牌。

在终端中输入如下命令:

# Set Git to use the credential memory cache
git config --global credential.helper cache

输入如下命令修改默认密码缓存超时时间。

# Set the cache to timeout after 1 hour (setting is in seconds)
git config --global credential.helper 'cache --timeout=3600'

macOS解决方案

我只是按照下面的说明,这就解决了我的问题。

为GitHub生成一个个人访问令牌。生成令牌的过程 打开您的钥匙串访问。 搜索github.com,双击它。 用最近生成的密钥更新密码。

注意:我不确定这是否适用于其他操作系统用户。