VS2019 Team Explorer--Use of Git (1)


2020-12-12

VS2019 16.8 has updated the team explorer, if you use the VS team explorer without the following Git function interface, please refer to this article  VS2019 16.8 "disappeared" team explorer


foreword

This article is about Team Explorer, which is simply Git for VisualStudio.

The Git software we use on the Windows platform is Git for Windows. There are two official ways to open it: bash and GUI, as follows:

Among them, bash is the most common command-line opening method on the Internet, git clone git checkout.. These commands are all used in bash. This GUI can also be used, but the interface is a bit crude.

In addition to the official set of tools, GitHub has written a set of GithubDesktop tools for use as Git GUI under Windows. The interface is indeed much better than the native GUI, and you can also directly log in to your Github account and use SSH to Clone . But the functions are not rich enough, and some functions still need to open bash to enter command operations. The following is the interface of GithubDesktop:

The VS team manager, like GithubDesktop, is also a Git GUI based on Git for Windows. That is, the commands are all executed by Git for Windows, and VS is only responsible for converting the UI operations of the interface into corresponding command lines and sending them to Git for Windows. Different from Github Desktop, this thing is directly embedded in VS as a manager. The interface is as follows:

At present, VS's team manager is the most convenient Git tool I use.

installation steps

1. Open Visual Studio Installer

2. Search git in a single component to install two components:

3. After installation, open a Github website and try:

The Open in Visual Studio tab will be added under Clone or Download. After clicking, a prompt to open an external application will appear. At this time, clicking Yes will open the VisualStudio team manager and fill in the content of git clone.

Git practice

The warehouse operated below takes Github as an example, because it is the most commonly used. This is a sample project https://github.com/JustLuoyu/vs2019-cmake-template I created under Github :

Clone

The Clone operation is to download the cloud project to the local as a local copy. You can use this copy to compile what you want, or you can develop the features you need based on this copy, and finally submit it to the remote project. So generally use git The first operation is Clone: ​​a local clone of the code repository.

1. Click Clone on Github to get the address of the warehouse:

2. There are two ways to clone in VS: one is to directly open VS through the Github extension of VS to clone, and the other is to copy the warehouse address to VS to clone.

a. Clone through the Github extension of VS (this may require browser support):

b. Open the Github link through the VS creation project tool:

The interface for cloning the repository appears:

The repository location in the picture above is this link under Github: [email protected]:JustLuoyu/vs2019-cmake-template

Note that this is the SSH address. The SSH protocol needs to manually configure the SSH public key to Github (GithubDesktop does not need it). If you are not familiar with it, click Use HTTPS and use the HTTPS protocol:

Copy to VS's repository location:

After clicking Clone, the files from the server will be pulled:

Description of Team Manager

1. Switch to Team Manager

2. Home page introduction:

3. The specific usage of the above function keys is demonstrated in the following example

Commit

This is to submit changes, usually submitted to the local warehouse, but VS provides the function of submitting and pushing, and can also be submitted directly to the server.

Let me demonstrate and modify the content of README.md first:

Save and go back to team admin changes:

Let's focus on the changed interface:

Let's ignore the .vs folder first:

In the above figure, there are two options: delete and ignore local items in the right button. Ignore local items means: Although this file is needed locally, I don’t need to upload it to the server for version control, and it can be dynamically generated. Delete means: this file Neither server nor local is required.

At this time, it becomes two changed files, as follows:

.gitignore is the change brought by the ignore operation just now, you can double-click to see:

As above, you can directly see the changed code location through the difference tool of VS.

Here I first do a submission operation directly to Github:

Select all to submit and push, and the push is successful as follows:

If it fails, it is usually a network problem. Try more. The picture on the right of the above picture is the Git output window. If it fails, find the git error code here and search for solutions online.

By the way, since Github uses the AWS cloud server, accessing it in China is sometimes extremely painful. It is best to use a ladder to pull the code. If there is no ladder, you can also modify the ip of the hosts to solve it a little:

I won’t specifically talk about how to increase the speed here, because these IPs are also changing all the time, and it may be easy to use today but not tomorrow. 

Go back to Github to view the pushed commits:

The commit above actually demonstrates two functions: commit and sync. 

Branch

The branch function here mainly demonstrates the operation of creating a new branch and switching branches.

new branch

1. Create a new TestBranch branch

2. Detailed explanation of the branch interface:

There are two high-level functions above: merge and rebase, which will not be introduced here for the time being, otherwise a bunch of Git framework things will be pulled.

3. Push the branch to the cloud:

Note that a green arrow is added to the icon in front of TestBranch in the picture above, which means that the branch is tracked in the cloud.

switch branch

Double-click a branch directly to switch, and the highlighted name will be displayed after the switch is successful.

That's all for the time being, there should be one or two articles related to git. One is to supplement the git operations that are not mentioned in this article, and the other is to demonstrate the warehouse operation of Microsoft's own Azure code cloud.

Guess you like

Origin blog.csdn.net/luoyu510183/article/details/106888059