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

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


当前回答

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

其他回答

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

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

如果你用的是macOS

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

GitHub已禁用密码认证,且不再支持密码认证。创建并使用个人访问令牌(PAT)而不是密码。

以下步骤:

Remove GitHub stored credentials from the keychain. (For example, using "Keychain Access" on Mac, or "Credential Manager" on Windows) Generate access-token from GitHub Settings → Developer Settings → Personal access tokens → Generate new token Save the token - as it will be available there for once only Run command git fetch (or git push, if fetching doesn't require permissions) If on Windows, you must run this from PowerShell, not the command prompt (CMD). The command prompt consistently fails with the remote: Password authentication is temporarily disabled message, despite identical inputs. It will ask for your user name and password. If it does not ask you for your username and password, you must change your Git remote URL to contain your username: https://USERNAME@github.com/repo-owner/repo-name.git (see approach 2 for instructions on changing remote URL) Use the access token instead of the password when it asks for a password (you will have to enter it twice)

或者第二种方法:

从GitHub生成访问令牌: 设置→开发人员设置→个人访问令牌→生成新的令牌 在本地更新origin的URL: git remote set-url origin https://<token>@<git_url>.git 拉一次:git拉https://<token>@<git_url>.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

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

使用密码的旧方法:

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