Home  >  Article  >  Development Tools  >  How vscode uses git to manage code

How vscode uses git to manage code

王林
王林Original
2020-01-09 09:47:597407browse

How vscode uses git to manage code

1. Install the git source code management system

In order to use VS Code to edit source code, you first need to install the source code management system. It is recommended. Use Git. To install Git on Windows, you can directly download the installation program from the Git official website.

During the installation of Git, select VS Code as the default editor for Git. Use the default options in the following steps. Keep clicking Next to complete the installation.

How vscode uses git to manage code

1. Configure the global settings of Git

After the installation is complete, use the git config command to make global settings for Git:

git config --global user.name "your name" 
git config --global user.email "your email address"

Because Git is a distributed version control system, each machine must report its name: your name and email address.

2. Clone the remote library

Create a local library, create a folder locally, and clone a local library from the remote library:

cd d:/GitTest   //指定存放的目录
git clone https://git.oschina.net/name/test.git   //你的仓库地址

2. Put VS Code is related to Git

Open the local library through the main menu File -> Open File of VS Code, so that VS Code can use Git for source code management.

How vscode uses git to manage code

Open "File Management" and you will see the GITTEST local folder, which is the local library managed by Git:

How vscode uses git to manage code

Open "Source Code Control" and you can see that SOURCE CONTROL is GIT. Click "√" to provide code modifications, and all code modifications are shown in the CHANGES list:

How vscode uses git to manage code

3. Use PowerShell scripts

Use PowerShell scripts to assemble git commands. In this way, you only need to execute a PowerShell script to complete code submission and synchronization:

git pull origin master
git add -A
git commit -m 'auto commit'
git push origin master

In VS Code, to execute a PowerShell script, you first need to set the execution policy, start the PowerShell terminal with administrator rights, enter the following command, and enter A:

Set-ExecutionPolicy RemoteSigned

How vscode uses git to manage code

Recommended related article tutorials: vscode tutorial

The above is the detailed content of How vscode uses git to manage code. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn