如何将 GitHub 个人访问令牌添加到 Visual Studio Code [英] How to add a GitHub personal access token to Visual Studio Code

查看:31
本文介绍了如何将 GitHub 个人访问令牌添加到 Visual Studio Code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到了一封电子邮件说 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 repository.

现在我想使用令牌从 GitHub 中推送/拉取我的存储库,在 Visual Studio Code 中,它使用 Git 和命令行,我已经安装在我的 Mac 上.

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

如何使用我刚刚创建的生成的令牌添加/替换来自 GitHub 的密码以从我的存储库中推送/拉取?我可以从 Visual Studio Code 中添加还是从终端命令行添加?

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

推荐答案

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

Follow these simple steps to set up GitHub authentication with a personal access token:

  1. 在您的 PC 或 Mac 终端上打开命令行窗口

  1. Open a command line window on your PC or Terminal on Mac

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

Set the current directory to your project root

cd C:UsersGiddysource
epoMySampleProject

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

  • Run the command to set remote access via a 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
    

  • 这篇关于如何将 GitHub 个人访问令牌添加到 Visual Studio Code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆