Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How VSCode uses Git to visually manage source code

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article "how VSCode uses Git to visually manage source code" is not quite understood by most people except programmers. Today, in order to make you better understand "how VSCode uses Git to visually manage source code", the editor summarizes the following content, which has a certain reference value, detailed steps are clear, and details are handled properly. I hope you can get something through this article. Now let's take a look at the details.

What is the use of vscode Visual Studio Code is a cross-platform editor for writing modern web and cloud applications, which runs on OS X web Windows and Linux. It provides developers with built-in support for a variety of programming languages, and as Microsoft pointed out in keynote at the Build conference, this editor also provides rich code completion and navigation features for these languages.

Environment preparation: 1. First of all, you need to install Visual Studio Code now.

Download address: https://code.visualstudio.com/Download

Select the corresponding platform to install (I am the installed window platform myself):

2. Git environment installation:

Git installation detailed tutorial: https://blog.csdn.net/qq_43715354/article/details/108638061

Clone the repository in GitHub: 1. Copy the SSH link address of the GitHub repository:

2. Open VS Code, click Clone, and paste the link address of SSH to download:

View the current branch: 1. Interface view:

2. Switch to the terminal and command to view: git branch-a

[* important] practical work development four steps (add, lift, pull, push): first of all, it is necessary to understand which four steps are the four steps and what are their functions?

Add: add the modified content to the local scratch area git add.

Note: submit the contents of the local scratch area to the local code base git commit-m 'description'.

Pull: synchronizing and pulling the contents of the remote code base is very important in multi-person collaborative development, because if there is no synchronous update to the latest version in advance, it may overwrite what others have modified, and if there is a conflict after pulling, you can use VS Code to resolve the conflict directly. Git pull.

Push: push the contents of the local code library to the remote code repository git push.

Add staging area:

Add an Information.txt text file to the local staging area.

Submit the local code base:

Pull the synchronous remote up-to-date code base:

Push to the remote code base:

Verify that the push is successful, and view the contents of the repository in GitHub:

Conflict resolution:

Next, let's simulate the multi-person development by ourselves. For example, I modify the contents of the Information.txt text file locally, and then modify it once in GitHub so that there will be conflicts when they are submitted locally, and then we can use VS Code's intelligent conflict resolution method to help us resolve conflicts.

Local modification:

Modifications in GitHub:

After local submission, the prompt conflicts when pulling are as follows:

Merge conflicts are submitted to the remote code library:

VS Code provides four intelligent merging methods for us to choose from, and we can resolve code conflicts according to the actual situation. Of course, it can also be deleted manually, but be careful. You may accidentally overwrite the code that your colleagues have worked so hard to write for several days. Here I choose the method of [keeping changes between both parties] to resolve the conflict.

Perfect conflict resolution:

Create a branch and push it to the remote code base: 1. Switch to the source control view:

2. Select the main branch that needs to create a sub-branch:

Note: here we create a feature-20210218 branch for the develop branch.

3. Push the new branch to the remote code base:

After the sub-branch is developed, it is merged into the main branch:

First we create a folder and a text file in the feature- 20210218 subbranch, and then merge the feature- 20210218 subbranch into the develop development branch and submit it to the remote code base.

1. Create a folder and a file in the feature- 20210218 sub-branch:

2. Use the actual work development four-step (add, lift, pull, push) tutorial to push the newly added content to the remote code base:

Switch to the feature-20210218 branch:

Check to see if the file was submitted successfully:

3. Merge the feature- 20210218 subbranch into the develop development branch:

a. First, switch to the develop branch:

b. Select the branches that need to be merged:

c. Push to the remote warehouse to see if the merge is successful:

VS Code Git submit modification history view (for throwing pot only):

Git History extension needs to be installed.

View the modification history of the corresponding file:

View the file modification timeline and compare the file changes:

Thank you for your reading, I hope you have a certain understanding of the key issue of "how VSCode uses Git to visually manage source code", and the specific usage needs to be understood by everyone through hands-on experiments. Try it quickly. If you want to read more articles about related knowledge points, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report