更新 GitHub 的个人令牌

3

我的GitHub个人访问令牌已过期,我真的不知道如何在命令行上更新个人访问令牌。

git push
Password for 'https://PERSONAL_ACCESS_TIME@github.com': 
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead. remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/
for more information.
fatal: Authentication failed for 'https://github.com/myuser/myrepor.git/'

非常感谢您的帮助,因为我感到非常困惑。


5
你是否阅读了 https://docs.github.com/cn/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token 上的说明?你卡在哪个步骤了? - IMSoP
我已经阅读了Github文档,URL中包含旧的标记,我无法弄清如何更新它。 - Swatcat
1
那么你的问题是关于找到令牌被“保存”的位置,而不是重新生成它? - IMSoP
2个回答

4

您可以使用GitHub命令行创建一个新的登录,并使用新的/重新生成的令牌

  1. 安装GitHub CLI:

    brew install gh

  2. 登录到gh:

    gh auth login

  3. 按照步骤操作,粘贴需要时您的令牌 本教程的步骤


3
你不应该将令牌保存在URL中。这是不安全的,因为任何能够读取配置文件的人都可以看到你的凭据。Git FAQ解释了如何设置和使用凭据助手
要从URL中删除令牌,请执行以下操作:
$ git remote set-url origin https://github.com/myuser/myrepor.git

然后,在设置了凭证助手之后,当您推送时,Git会提示您输入凭据。在提示时输入您的用户名,并在要求密码时提供令牌。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接