当前位置: 首页 > java >正文

如何在 Visual Studio Code 中配置SSH、Git 和 Copilot插件

如何在 Visual Studio Code 中配置SSH、Git 和 Copilot 插件

  • 1- 先决条件
  • 2- 在 Visual Studio Code 中安装、配置和连接 Remote-SSH 扩展
    • 2.1 安装 Remote-SSH Extension
    • 2.2 配置 SSH connection
    • 2.3 连接 Remote Host
  • 3- Installation, configuration and use of Git Extension in Visual Studio Code
    • 3.1 Install Git
    • 3.2 Configure Git in VS Code
    • 3.3 Use basic Git
  • 4- Installation and use of the GitHub Copilot Extension in Visual Studio Code
    • 4.1 Install GitHub Copilot Extension
    • 4.2 Use GitHub Copilot Extension
    • 4.3The problem encountered and its solution:

1- 先决条件

  • 1.1 确保已安装 VS Code (VS 官方网站)

    • 暂时请勿安装最新版本1.100.x,请选择 1.98.2 或以下版本
    • 推荐 VSCodeUserSetup-x64-1.98.2.exe
  • 1.2 需要激活的互联网连接

  • 1.3 GitHub Copilot 账户

2- 在 Visual Studio Code 中安装、配置和连接 Remote-SSH 扩展

2.1 安装 Remote-SSH Extension

**1. 打开Visual Studio Code Extensions **

  • 使用 Ctrl+Shift+X shortcut key 或者点击 左侧的 ‘Extensions’

2. 搜索并安装Extension

  • 由于目前最新的版本 (0.120.0)有问题, 在还没有被解决以前最好避免去使用它
  • 如果你现在安装了最新的Remote-SSH (0.120.0) , 你需要去uninstall 并且去安装早一个版本 (i.e. 0.119.0).
  • 然后在搜索框输入 Remote-SSH 并且点击安装

3. 验证安装

  • 当Remote Explorer’ 图标出现在左侧活动区, 说明该extension已经被安装成功了
    在这里插入图片描述

2.2 配置 SSH connection

1. 生成SSH key(如果你目前还没有)

  • 命令是:
ssh-keygen

2. 添加public key到 remote host(可选择的)

  • 如果你想要登录远端机器时不输入密码,就需要手动做这一步
  • 手动复制 ~/.ssh/id_rsa.pub内容到远端机器的 ~/.ssh/authorized_keys 文件中
  • 请注意是追加,并不是覆盖文件

3. 在VS Code添加 host

    1. 点击VSCode左侧的‘Remote Explorer‘
    1. 下面的图片会出现, 点击SSH右侧的 ‘+’ (New Remote) 去添加一个新的SSH Host在这里插入图片描述
    1. 输入连接命令
      在这里插入图片描述

      • 输入命令的格式:
ssh username@remote_host_ip
    1. 接着选择 config file保存的位置 (第一行就是默认的位置, ~/.ssh/config)
    1. 当你看见VSCode右下角出现了 ‘Host added’ ,说明host添加成功了在这里插入图片描述

2.3 连接 Remote Host

1. 初始化连接

  • 点击REMOTES(TUNNELS/SSH)‘右边的Refresh’
  • 你配置的机器就会出现在SSH下方
  • 点击目标主机并且选择 ‘Connect to Host in New Window’

2. 检查连接状态

  • 当屏幕的左下角出现’SSH:remote_host_ip’ , 说明远程连接机器成功

3. 打开remote project

  • 点击 File→Open Folder 并且去选择远端机器的目录

3- Installation, configuration and use of Git Extension in Visual Studio Code

3.1 Install Git

1. Download and install Git

  • Windows: Visit the Git official website to download the installer

2. Verify installation

  • The command:
git --version
  • The version number is displayed after a successful installation

3.2 Configure Git in VS Code

1. Install Git Extension

  • VS Code has built-in Git support, so there is no need to install any additional extensions
  • For enhancements, search for ‘GitLens’ . Use the Ctrl+Shift+X shortcut key or click Extensions on the left side of the VS Code
  • Then type GitLens in the search box, click Install

2. Set Git user info and check
Set Info

    git config --global user.name "your name"git config --global user.email "your.email@example.com"

Check Configuration

    git config --list

3.3 Use basic Git

1. Clone a remote repository

  • Get the repository URL
  • Clone in VS Code
Open VS Code and press ' Ctrl+` '
Run command : git clone Repository URL

2. Open the cloned repository

  • Load project
    Click File→Open Folder and select the cloned repository directory
  • Verify repository status
    Click … -> Terminal-> New Terminal, Then type the git command in the termainal box below

4- Installation and use of the GitHub Copilot Extension in Visual Studio Code

4.1 Install GitHub Copilot Extension

1. Open Visual Studio Code Extensions Marketplace

    1. Use the Ctrl+Shift+X shortcut key or click Extensions on the left side
    1. Search and install Extension
      • Then type GitHub Copilot in the search box, click Install
      • The same way you can install the GitHub Copilot Chat Extention
    1. Verify installation
      • The GitHub Copilot Extension has been installed successfully when a small robot icon appears in the bottom right corner and we are prompted to log in to our GitHub accont
      • The GitHub Copilot Chat Extension has been installed successfully when two intersecting text boxed appear in the left column
    1. Sign in with your GitHub Copilot account

4.2 Use GitHub Copilot Extension

1. Assisted Programming

  • As you write code, Copilot will automatically provide you with suggestions based on the context
  • Press the Tab key to select the suggestion, or press Enter to accept it
    2. Chat about specific lines of code
  • We can input any questions to GitHub Copilot Chat by click chat icon

4.3The problem encountered and its solution:

- The problem:
A locally installed GitHub Copilot is only available in your local instance of VS Code and will not be synchronised with the remote machine.
- The solution:
You also need to install GitHub Copilot on the remote machine.

http://www.xdnf.cn/news/13886.html

相关文章:

  • NineData 社区版 V4.2.0 发布!新增MySQL与PostgreSQL互相迁移,SQL管理Milvus,安装更高效
  • .NET Core 数据库连接字符串加密与解密
  • PHP设计模式实战:领域驱动设计与六边形架构
  • 深度分页优化
  • MySQL-DDL语句深度解析与实战指南
  • mac安装mvnd结合idea
  • C++中的零拷贝技术
  • 【QT系统相关】QT文件
  • 国标28181卡顿问题现场诊断报告
  • 对象注入 BeanFactory 的操作 BeanFactoryPostProcessor , Spring boot
  • 【信创-k8s】重磅-鲲鹏arm+麒麟V10离线部署k8s1.30+kubesphere4.1.3
  • 华为云Flexus+DeepSeek征文 | 当大模型遇见边缘计算:Flexus赋能低延迟AI Agent
  • Blender 简介 ~ 总结,如何下载Blend格式模型
  • 保姆级安装OpenResty教程
  • 视觉语言模型的“视而不见“
  • 【Linux仓库】进程状态【进程·叁】
  • 三步走实现嵌入式硬件与软件开发
  • 芯科科技携最新Matter演示和参考应用精彩亮相Matter开放日和开发者大会
  • Axios面试常见问题详解
  • ELK1日志分析系统
  • GD32 MCU的真随机数发生器(TRNG)
  • 商业智能BI 企业提高数据质量,应该怎样保障数据治理有效性
  • HTTP 协议各个主要版本的功能特点、核心原理、使用场景总结
  • 算法学习的规范性和可持续性
  • 关于亚马逊WOOT周末大促
  • 解锁嵌入式Linux开发:从入门到精通的通关秘籍
  • 第二节 基础核心概念-any、unknown、never的区别
  • 江苏艾立泰:跨国循环经济破解塑料行业环保困局
  • 网络编程之HTML语言基础
  • 五、PyQt6图形用户界面