How to Use Git with VS Code

Git is a tool for synchronizing basically your code to a web repository or a local server repository. Github is a public hub of code reposities.

In order to use Github, You need to create your account firstly.

In general situation, an account with community plan is enough for using.

Then, install Git from the official website.

Following that, install VS Code from the official website.

If you don't have a set of SSH key on your system, open the Git Bash or just the Bash and type the command below, which will create an SSH key for you:

ssh-keygen

Naviagte to the directory "~/.ssh",  copy the contents of "id_rsa.pub" and paste it in the settings page of your github account. You should open the webpage of Github and find the setting in a tab named "Access/SSH and GPG keys". After these steps, you can link to github using ssh protocol. Following command could test if the SSH key is properly installed.

ssh -T git@github.com
Create a repository in the github webpage.

Open your VS code, press "Ctrl+Shift+P" and type "git". Select the option which could clone a remote repository. 

Next, you can use the local repository to manage your codes. By pressing "Ctrl+Shift+G", you can control your repository with most kinds of git function.

In order to push your codes to Github, you should stage your modifications in local repository and submit these modifications. Last, you can pull the changes in remote repository and push the local repository to the remote repository then.

评论

此博客中的热门博文

移动硬盘+miniconda:可以带着走的Python虚拟环境

CaImAn(Python版)的使用

使用大模型辅助Python编程的示例——excel数据生图