我使用用户名密码来推送我的代码。它工作了几个月,但突然我不能这样做,并得到这个错误:
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计划的一部分,很快将是永久的服务变化
之前接受的Kusal Shrestha的答案可以完成这项工作,但它并不安全,因为我们将令牌存储在纯文本中。
在我看来,将它存储在钥匙链中是更好的方法。
对于Visual Studio Code,请阅读crg的回答。
Windows:
你可以试试下面的@Venryx评论,但我还没有测试过。
Mac:
我现在才面对这个问题
按照建议,我按照这个URL进入开发设置并生成了一个令牌。
然后我进入我的Mac的钥匙链访问:
我删除了(所有)行的GitHub
现在我去终端输入了虚拟代码
git push
终端要求我输入我的邮箱和密码。
我输入了我的电子邮件,对于密码,我输入了我之前生成的令牌。
然后它又开始工作了。
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
输入从个人访问令牌生成的个人访问令牌。
适用于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
不是推就是拉
它将提示您一个模态对话框。单击“允许”并按照流程操作。