如何将 github 个人访问令牌添加到 Visual Studio 代码

问题描述:

我收到了电子邮件Github 将在 2021 年 8 月 13 日之后要求令牌身份验证.我想确保在此日期之后我不会中断服务(推/拉).所以我登录到 Github 并创建了一个令牌 用于我的单个存储库.

I received an email saying Github will require token authentication after August 13 2021. I want to ensure I don't have an interruption of service (push/pull) after this date. So I logged into Github and created a token for my single repo.

现在我想使用令牌在 Visual Studio Code 中从 Github 推/拉我的 repo,它使用 git 和命令行,我已经安装在我的 Mac 上.

Now I want to use the token to push/pull my repo from Github, in Visual Studio Code, which uses git and the command line, which I have installed on my Mac.

问题 - 我该怎么做才能从 Github 中添加/替换我刚创建的生成令牌以从我的存储库中推送/拉取的密码?我可以从 Visual Studio Code 中添加,还是从终端命令行添加?

QUESTION - What do I do to add/replace the password from Github with the generated token I just created to push/pull from my repo? Can I do it from Visual Studio Code or does it get added from the terminal command line?

按照这些简单的步骤,使用 个人访问令牌

Follow these simple steps to setup Github authentication with Personal Access Token

  1. 在 PC 上打开命令行或在 Mac 上打开终端

  1. Open Command line on your PC or Terminal on Mac

将当前目录设置为您的项目根目录

Set the current directory to your Project root

>cd C:\Users\Giddy\source\repo\MySampleProject

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

Run the command to set remote access via token

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

示例:

>git remote set-url origin https://sampleuser:a7b19929***58fe65d1c@github.com/sampleuser/sampleproject.git