Visual Studio Code uses git for version control

Source: Internet
Author: User
Tags git commands

Visual Studio Code uses git for version control

  • Please make sure you have the latest VS Code installed. http://code.visualstudio.com/
  • Make sure you have the latest version of Git installed. https://git-scm.com/download. git installs into the environment variable,   ensures that any path can be accessed.
  • reference link: https:// Code.visualstudio.com/docs/editor/versioncontrol

VS code integrates GIT functionality and supports basic GIT commands, which allows us to easily submit and fetch code during the development process.

1.1 Initialization

First we create a folder named Gittest, and of course it's not in Git's versioning management.

Open this folder with VS Code and click on the Git icon on the left.

We can see the "Initialize Git repository" button, click.

After initialization, the first thing we see is that the Git bar shows all the current files, with 4 changes.

All or individual files can be staged or cleaned out.

There are more options in the drop-down menu, with the Submit and Refresh buttons above. Back to our file, the operation just created a. git folder and placed all the configuration files for the current repository, such as.

So far we've created a code repository locally, and here's a look at the git functionality of VS code.

git output

We can choose the git output in the hidden menu so that each of our actions will be displayed in the output area, allowing us to view the corresponding GIT commands.

Commit Save

The first step in the commit save is to scratch the file.

The second step is to enter the submission information.

The third step then submits all changes using the Submit button of the status bar.

git command list

Ctrl+shift+p, enter git and see all of the GIT commands supported by vs code.

Undo Action

Enter undo last Commit to undo the previous operation. Enter Unstage to undo the staging.

Branch

Enter branch to create a branch of the current content. You need to enter a branch name when creating a branch.

Checkout

After you create the branch, you can use the checkout command to pull specific branch content.

Conflict merging

VS Code detects file conflicts and distinguishes them by <<<<<,>>>>,==== and colors.

After the conflict is resolved, the direct submission is OK.

File comparison

In the list of git files, click a file that does not commit changes, and a two window opens to display the contents of the change.

Connecting remote code Warehouses

Said so much, now the problem comes, in the native initialization of a code base, generally no eggs. Most of us are going to connect to a remote code server.

Below we create a repository on GitHub, copy the address to be reserved.

Next to the current Repository folder root directory, if not initialized, the installation article begins initializing the method that is initialized. Then execute the following command

git remote add origin https://github.com/xuanhun/vscode.gitgit pull origin master

Now let's take a look at the config file under the. git folder and see the remote reps address added.

Next we execute the Publish command from the drop-down menu.

This will remind us to enter your account number and password.

Once entered, the locally submitted files are synced to GitHub. After syncing and then open the Git hidden menu, you can see the synchronization and other commands can be used directly.

A way to simplify a little bit

Of course we can also use the git clone command to clone a reps from a remote, then open the folder directly with Vscode, and the VS Code will automatically recognize the configuration.

Persistent account

The problem with remote connection to Git is solved, if you don't want to enter account information every time you sync, you can store your account globally to solve this problem.

git config --global credential.helper wincred
Summary

Most of the content of this article can be found in the official documents, but many Chinese tutorials do not solve the problem of connecting remote services, so specifically to do a description, I hope to help you. Finally, this article, as an experimental content, synchronizes to GitHub with the address: VS Code integrated with Git


More exciting content, focus on the Soul Studio subscription number:


Visual Studio Code uses git for version control

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.