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

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推送时,输入您的用户名,密码是生成的令牌

无需为每个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'

其他回答

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

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

我今天下午遇到了这个问题,并通过将参考文献3中所述的GitHub密码替换为参考文献2中生成的令牌来解决这个问题。

参考文献1:参见API和Git操作的令牌身份验证要求。不再支持该密码。 参考文献2:因此,您应该在本教程中生成一个令牌,并使用它代替您的密码作为凭据。 参考资料3:如果没有提示您输入用户名和密码,则您的凭据可能缓存在您的计算机上。您可以在Keychain中更新凭据,用本教程中描述的令牌替换旧密码。

我试了所有的方法,最后都奏效了。由于这个错误,我无法在我的存储库中推送,所以请至少尝试一次!

_____________________________ 生成个人访问令牌:

点击这里并生成一个个人访问令牌。这太简单了。 https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token 现在只需在PAT的帮助下按一下,而不是密码和用户名___________________ 要将更改推送到存储库: git push https://[个人访问令牌]@github.com/[用户名]/[存储库名称].git

如果你用的是macOS

首先请删除密钥链中的所有GitHub凭证,然后请生成您的令牌作为您的密码(由于GitHub安全策略):GitHub*→设置→开发者设置→个人访问令牌。 尝试将一些最新的内容推入或拉出存储库。然后Git会询问您的用户名和密码。输入您的用户名和从GitHub生成的令牌。

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

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