【问题标题】:how to use Personal access token to clone, pull, and push a repo? [duplicate]如何使用个人访问令牌克隆、拉取和推送存储库? [复制]
【发布时间】:2021-09-12 21:49:12
【问题描述】:

今天 GitHub 推出了一种推送、克隆或拉取 repo 的新方法,让我大吃一惊

当我尝试推送我的项目时,我收到以下错误消息:

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.
fatal: unable to access 'https://github.com/barimehdi77/Philosophers.git/': The requested URL returned error: 403

经过多次搜索,我发现 GitHub 添加了一个名为 Personal access tokens 的新安全更新,但我可以使用谁?

【问题讨论】:

  • 请将文本作为文本发布。不要发布文字图片。
  • 请原谅我在这里跳了一点——你考虑过使用 SSH 密钥进行 github auth 吗?
  • 你读过他们链接的文章吗?您可以使用令牌。
  • 是的,我使用了 SSH 密钥,但我更喜欢,但我不喜欢它,因为我使用多台 PC
  • @JBallin 是的,我读过它并生成了令牌,但我不知道如何重置密码

标签: git github


【解决方案1】:

您必须使用 SSH 密钥。为每台计算机创建一个并将它们全部注册到您需要访问的存储库中。这样做可以让您通过计算机删除访问计算机。

在 Github 中配置好 SSH 密钥后,您可以阅读本文来设置个人访问令牌。

https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token

UPDATE它告诉你如何更改文档中的令牌

在命令行中使用令牌

获得令牌后,您可以在以下情况下输入令牌而不是密码 通过 HTTPS 执行 Git 操作。

例如,在命令行中输入以下内容:

$ git clone https://github.com/username/repo.git <--- HTTPS, not SSH
Username: your_username
Password: your_token <-------- THE TOKEN, not your password

个人访问令牌只能用于 HTTPS Git 操作。如果 您的存储库使用 SSH 远程 URL,您需要切换 远程从 SSH 到 HTTPS。

如果系统未提示您输入用户名和密码,您的 凭据可能缓存在您的计算机上。您可以更新您的 钥匙串中的凭据以将旧密码替换为 令牌。

无需为每个 HTTPS Git 操作手动输入 PAT, 您可以使用 Git 客户端缓存您的 PAT。 Git将临时存储 您的凭据在内存中,直到过期间隔过去。你 还可以将令牌存储在 Git 之前可以读取的纯文本文件中 每一个请求。有关更多信息,请参阅“缓存 GitHub Git 中的凭据。”

还找到了一个很好的视频演练,可能有助于弄清楚一些事情。

https://www.youtube.com/watch?v=kHkQnuYzwoo

【讨论】:

  • 我阅读了这篇文章,但我不知道如何使用令牌重置我的密码,所以我首先问了这个问题
【解决方案2】:

以前的密码无效。您必须使用令牌作为密码。

$ git clone https://github.com/username/repo.git
Username: your_username
Password: your_token

您可以按照以下步骤创建令牌:

https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token

【讨论】:

  • 我确实创建了令牌,但是如何用新密码替换我最旧的密码
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-11-22
  • 2019-09-26
  • 2021-12-08
  • 2019-08-22
  • 2021-12-23
  • 2012-03-15
相关资源
最近更新 更多