【问题标题】:How to update a GitHub access token via command line如何通过命令行更新 GitHub 访问令牌
【发布时间】:2022-01-13 21:45:09
【问题描述】:

我使用 VSCode 的 git 集成,今天收到通知,我需要更新我的访问令牌。我这样做并获得了我的新令牌(我通过网络界面获得)。现在我需要设置我的本地 git 配置以使用新令牌而不是几天后过期的旧令牌。

VSCode docs 建议如下:

要执行“GitHub:设置个人访问令牌”,在 VSCode 中键入 Ctrl+Shift+p 以打开命令面板并键入“GitHub:设置个人访问令牌”。然后将提示您输入从 GitHub 生成的令牌。

此选项在我的 VS 代码中的 git 集成中不可用(也许我需要更新?)

如何从命令行执行此操作?

【问题讨论】:

    标签: windows git visual-studio-code access-token


    【解决方案1】:

    如果要在VSCode中更新Github Personal Access Token,需要安装Github Extension

    您也可以通过命令行更新 Github Personal Access Token

    1. 打开命令行并将当前目录设置为您的项目根目录

    2. 运行命令以通过令牌设置远程访问

      git remote set-url origin https://username:token@github.com/username/repository.git

    例子:

    git remote set-url origin https://exampleuser:b8c28127***63gu56b2d@github.com/exampleuser/exampleproject.git
    

    【讨论】:

      猜你喜欢
      • 2021-10-19
      • 2020-01-06
      • 1970-01-01
      • 2014-09-13
      • 2012-06-19
      • 2016-08-13
      • 2021-02-01
      • 2018-06-13
      • 2011-10-06
      相关资源
      最近更新 更多