How to set up SSH, Git and Copilot Extensions in Visual Studio Code

How to set up SSH, Git and Copilot Extensions in Visual Studio Code

  • [1- Prerequisites](#1- Prerequisites)
  • [2- Installation, configuration and connection of Remote-SSH Extension in Visual Studio Code](#2- Installation, configuration and connection of Remote-SSH Extension in Visual Studio Code)
    • [2.1 Install Remote-SSH Extension](#2.1 Install Remote-SSH Extension)
    • [2.2 Configure SSH connection](#2.2 Configure SSH connection)
    • [2.3 Connect to Remote Host](#2.3 Connect to Remote Host)
  • [3- Installation, configuration and use of Git Extension in Visual Studio Code](#3- Installation, configuration and use of Git Extension in Visual Studio Code)
    • [3.1 Install Git](#3.1 Install Git)
    • [3.2 Configure Git in VS Code](#3.2 Configure Git in VS Code)
    • [3.3 Use basic Git](#3.3 Use basic Git)
  • [4- Installation and use of the GitHub Copilot Extension in Visual Studio Code](#4- Installation and use of the GitHub Copilot Extension in Visual Studio Code)
    • [4.1 Install GitHub Copilot Extension](#4.1 Install GitHub Copilot Extension)
    • [4.2 Use GitHub Copilot Extension](#4.2 Use GitHub Copilot Extension)
    • [4.3The problem encountered and its solution:](#4.3The problem encountered and its solution:)

1- Prerequisites

  • 1.1 Ensure VS Code installed (VS Official Website)

    • For now, please don't install the latest version1.100.x , choose 1.98.2 or below
    • Recommended VSCodeUserSetup-x64-1.98.2.exe
  • 1.2 Active internet connection required

  • 1.3 GitHub Copilot account

2- Installation, configuration and connection of Remote-SSH Extension in Visual Studio Code

2.1 Install Remote-SSH Extension

1. Open Visual Studio Code Extensions Marketplace

  • Use the Ctrl+Shift+X shortcut key or click 'Extensions' on the left side

2. Search and install Extension

  • Due to some issues with the latest version (0.120.0), it is advisable to avoid using it until these are resolved
  • If you are currently in the process of installing the latest version (0.120.0) of Remote-SSH, you will need to uninstall it and install an earlier version (i.e. 0.119.0).
  • Then type Remote-SSH in the search box and click Install

3. Verify installation

  • When the 'Remote Explorer' icon appears in the left activity bar, the extension has been successfully installed

2.2 Configure SSH connection

1. Generate SSH key(If needed)

  • The command is:

    ssh-keygen

2. Add public key to remote host(optional)

  • If you want to log into the machine remotely without entering a password, do this step
  • Manually copy the contents of ~/.ssh/id_rsa.pub to the remote machine ~/.ssh/authorized_keys
  • Please note that this is an addition, not an overwrite

3. Add host in VS Code

    1. Click 'Remote Explorer' in the leftmost column of VSCode
    1. The following picture appears, click '+' (New Remote) on the right side of SSH to add a new SSH Host
    1. Enter the connect command

      • Input command format:

    ssh username@remote_host_ip

    1. Next select the config file save path (The first one is selected by default , ~/.ssh/config)
    1. When you see 'Host added' in the lower right corner of the VSCode, it means that the Host has been added successfully

2.3 Connect to Remote Host

1. Initiate connection

  • Click 'Refresh' to the right of REMOTES(TUNNELS/SSH)
  • The machine name you just configured will appear under SSH
  • Click on the target host and select 'Connect to Host in New Window'

2. Check connection status

  • When the lower left corner of the screen appears 'SSH:remote_host_ip' , indicates that the remote connection to the machine was successful

3. Open remote project

  • Click File→Open Folder and select the remote directory

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

3.1 Install Git

1. Download and install Git

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.

相关推荐
SStone_TJ5 小时前
【常用的git命令】
git
没有鸡汤吃不下饭6 小时前
Git将某个分支合并到开发(dev)、测试(test)后突然想撤销该分支的功能,怎么处理?
前端·git·github
康一夏6 小时前
git fatal:Server aborted the SSL handshake
git·网络协议·ssl
siriuuus13 小时前
Linux ssh/scp/sftp命令使用及免密登录配置
linux·ssh·sftp·scp
fakerth21 小时前
【Cursor/Vscode】SSH免密登录
ide·vscode·ssh
Vio7251 天前
在IntelliJ IDEA中使用Git
git
Net_Walke1 天前
git 的常用命令
git·物联网·github·iot
L X..1 天前
Git 无法访问 GitHub(Recv failure: Connection was reset)问题解决教程
git·github
建群新人小猿1 天前
客户标签自动管理:标签自动化运营,画像持久保鲜
android·java·大数据·前端·git
来一颗砂糖橘1 天前
Git 进阶指南:深入掌握 git log 查看提交历史
git·版本控制·开发技巧