代码之家  ›  专栏  ›  技术社区  ›  Swatcat

更新github的个人令牌

  •  -1
  • Swatcat  · 技术社区  · 4 年前

    我的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/'
    

    任何帮助都将不胜感激,因为我很困惑

    0 回复  |  直到 4 年前
        1
  •  4
  •   Ioane Faumui    4 年前

    您可以使用github命令行使用新的/重新生成的令牌进行新的登录

    1. 安装github CLI:

      brew install gh

    2. 登录gh:

      gh auth login

    3. 按照步骤操作,并在需要时粘贴您的代币 steps for this tutorial

        2
  •  2
  •   bk2204    4 年前

    您不应该将令牌保存在URL中。这是不安全的,因为任何能够读取配置文件的人都可以看到您的凭据。这个 Git FAQ explains how to set up and use a credential helper .

    要从URL中删除令牌,请执行以下操作:

    $ git remote set-url origin https://github.com/myuser/myrepor.git
    

    然后,在设置好凭据助手后,当你推送时,Git会提示你输入凭据。提示时输入用户名,提示输入密码时提供令牌。

    推荐文章