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

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


当前回答

如果你不想以纯文本形式存储你的令牌(通过修改远程回购的URL),你可以这样做:

通过遵循官方链接生成一个新的令牌 通过单击下面的按钮,确保复制了令牌。如果你双击文本并复制它,它会增加一个额外的空格,你会继续得到相同的错误(即使你不再使用你的密码,但令牌)

其他回答

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生成一个访问令牌,设置→开发者设置→个人访问令牌→生成新的令牌 保存令牌-因为它只在那里可用一次 在系统中搜索。git-credential文件 在该文件中,在用户名之后使用访问令牌而不是密码。

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

使用密码的旧方法:

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