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

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


当前回答

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

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

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

其他回答

Ubuntu服务器和现有Git存储库的解决方案

删除密码:

git config --global --unset user.password;
git config --local --unset user.password;

改变remote.origin.url。用你的GitHub用户名替换<用户名>:

git config --global --replace-all remote.origin.url "https://<username>@github.com/PPEProjects/smile-eyes-be.git";
git config --local --replace-all remote.origin.url "https://<username>@github.com/PPEProjects/smile-eyes-be.git"

拉/ push

git pull
git push origin HEAD:develop

输入从个人访问令牌生成的个人访问令牌。

从GitHub的开发者设置中生成一个新的令牌 更新远程URL: git remote set-url origin https://<token>@github.com/<Git_URL> 拉: git拉https://<token>@<Git_URL>.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中删除凭证

首先从帖子:API和Git操作的令牌认证要求,它说

2021年年中-所有经过身份验证的Git操作都需要个人访问或OAuth令牌。

所以你需要使用个人访问令牌(PAT)来推送:

1获取您的个人访问令牌

在这里登录以访问存储库并添加一个新的个人访问令牌:个人访问令牌。生成一个并保持令牌的安全(离开后无法显示它)。

(在Android Studio中,您需要获得“repo”,“gist”和“read:org”的许可)

2使用个人访问令牌进行推送

在你得到令牌后,你可以用如下命令进行推送:

git push https://[personal access token]@github.com/[user name]/[repository Name].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

你可以开始了!