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

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


当前回答

试试这个(对我很管用):

根据以下指南生成SSH密钥:生成新的SSH密钥 删除所有旧的远程使用HTTPS与git远程删除原点; 使用SSH引用添加一个新的远程(您可以通过存储库中的“code”按钮获得它,然后按“SSH”)。

其他回答

你不需要拆遥控器。添加一个新的,然后拉(根据已接受的答案)。

对我来说最简单的解决方案(在Linux上)是使用gh自动登录并遵循CLI指示。不需要采取进一步措施。

如果您没有gh,根据您的操作系统根据下面的链接安装它。

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

使用密码的旧方法:

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

如果您使用的是HTTPS

按照文档中的指示在令牌设置中生成一个令牌 如果存储库已经存在,则必须按照以下格式更改远程URL: https://<username>:<token>@github.com/<repository_url> Git远程删除原点 git remote add origin https://<USERNAME>:<TOKEN>@<GIT_URL>.git git拉#验证 如果克隆存储库 git克隆https://<USERNAME>:<TOKEN>@<GIT_URL>.git

如果你使用的是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

你可以开始了!

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

将HTTPS GitHub克隆转换为使用SSH