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

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仪表板生成您的PAT(个人访问令牌)。

Step 1: Log in to your GitHub account. Step 2: In the upper-right corner of any page, click your profile photo, then click Settings. Step 3: In the left sidebar, click Developer settings. Step 4: In the left sidebar, click Personal access tokens. Step 5: Click Generate new token. Step 6: Give your token a descriptive name. Step 7: Select the scopes, or permissions. You'd like to grant this token. To use your token to access repositories from the command line, select repo. Step 8: Click Generate token.

复制您的令牌到一个安全的位置,因为一旦您离开该页面,您将无法检索它,除非您创建一个新的。

其他回答

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

这样就可以开始了。

适用于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

不是推就是拉 它将提示您一个模态对话框。单击“允许”并按照流程操作。

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

您可以通过GitHub仪表板生成您的PAT(个人访问令牌)。

Step 1: Log in to your GitHub account. Step 2: In the upper-right corner of any page, click your profile photo, then click Settings. Step 3: In the left sidebar, click Developer settings. Step 4: In the left sidebar, click Personal access tokens. Step 5: Click Generate new token. Step 6: Give your token a descriptive name. Step 7: Select the scopes, or permissions. You'd like to grant this token. To use your token to access repositories from the command line, select repo. Step 8: Click Generate token.

复制您的令牌到一个安全的位置,因为一旦您离开该页面,您将无法检索它,除非您创建一个新的。

如果你用的是macOS

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