当尝试拉入或推送 GitHub 时,我收到一条错误消息:“请改用个人访问令牌。”

Wid*_*ogy 5 version-control github atlassian-sourcetree

我通过 SourceTree 使用版本控制作为 GitHub,但它从 8 月 13 日开始失败,以下是我从 GitHub 得到的错误。

远程:2021 年 8 月 13 日移除了对密码身份验证的支持。请改用个人访问令牌。远程:请参阅https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ 了解更多信息。

有人知道问题出在哪里,或者我如何使用个人访问令牌?

Sam*_* Su 22

由于 OP 正在使用 SourceTree,请执行以下操作:

  1. 在 Github 帐户设置中生成您的个人访问令牌
  2. 双击SourceTree中的一个仓库,点击Setting弹出窗口右上角的图标;
  3. 单击Remotes菜单选项卡,您将看到此存储库的远程 URL,应该是这样的https://github.com/username/repo.git
  4. 单击Edit并将其更改为https://<your_token>@github.com/username/repo.git

完毕

  • 这是非常糟糕的方式,这将使您的令牌(PAT)容易受到攻击,因为每个人都可以看到它。 (3认同)

Ter*_*nal 17

第1步:生成令牌:https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token

步骤 2:打开.git > config文件并替换 [remote "origin"] URL,如下所示

https://<username>:<githubtoken>@github.com/<username>/<repositoryname>.git
Run Code Online (Sandbox Code Playgroud)