Using Webstorm to manipulate git

Source: Internet
Author: User
Tags diff using git

0. Preface

In the previous article, we talked about using Webstorm to debug node programs and recently studied how to use Webstorm to manipulate git.

For the use of git, we use different ways, the most benevolent way non-command line mo, git-based GUI software is still a lot of, we can use their own research. Before using the Eclipse SVN plugin to operate version management, it's a very handy thing. Now used to webstorm, of course, it also integrates with SVN support, but has been using git recently, so want to try to use the Git integration tool in Webstorm version management. Of course, before all the way to hit the command line to do, to achieve a proficiency, the speed is very considerable. This article focuses on how to use the Git tools in webstorm for faster and more efficient version management.

1. Talk about Git theory first

Webstorm offers a lot of git attempts, as listed below:

We see a lot of options on the GIT panel above, and want to figure out what each option does, and the usual and regular git theory knowledge and operational experience is essential.

Let's look at a simple classification of GIT operations, as follows--

    • Remote Repository class: Git clone/remote/pull/push/rebase/fetch
    • Branch class (including tag): Git Branch/tag/checkout/stash
    • Information lookup: Git status/log/diff
    • Local normal operation: Git add/commit/rm/merge/reset

Here is just my personal classification, everyone has a different classification of it, welcome to add.

What you need to emphasize is that you need to have a clear grasp of what you want to do with the above command keywords, and if you don't know, don't take a look at the articles at the end of the article. To say a word, must combine the work area, the staging area, the version Library three relations to understand.

Combining the images given above, we can see that the Git tool in Webstorm is nothing more than a visual abstraction of these command lines, so let's see how to play it.

2. Using Git in Webstorm

2.1 Right-click menu

First, the most well-known right-click operation, divided into two categories: folder (or project) right-click and file Right-click, first look at the effect of folder right button--

And look at the file right button--

The difference between the two is that the view of the right-hand side of the file is more than a few diff operations (or you can think of git diff commands). Let's look at what each option means--

Commit File ... Submit to Local repository

Add into Buffer

Show current Revision Displays the latest version of the file, such as-

Compare with the same Repository version is compared to the current release (the file), which can be understood to be compared with the latest version, that is, the difference between the local workspace and the local repository can be compared (also remember that in the comparison view, the right side is always the latest version of the content)- —

Compare with Latest Repository version compared to the previous release (the file), it can be understood that the current version and the local workspace changes together to compare with the previous version

Compare with ... Compare with any historical version (file)

Compare with Branch ... Compare with any branch (file), including local branch and remote branch

Show history show associated with this file (or all the files in the folder) to submit information about the historical, we can see that the historical Submission information Panel appears in the following version control Panel--

Show history for Selection to the specified code block, displaying historical version information

(Connect the second figure)-------->>>>>>

Revert ... To restore the code, pay attention to the distinction between reset, which is simply to restore the local workspace code to the latest version of the local repository code

Repository > Warehouse Secondary navigation options, i.e. operations of related warehouse classes

Note that some operations are performed on a single file, and each time a folder (or a project) is manipulated, the action file is expanded and manipulated in the collection of selected files.

Let's keep looking at Respository's level two navigation--

Branches shows left and right branches, including local and remote branches

Further operations can be performed on each branch, as shown in

Or

    • Checkout checked out to the local workspace, at which time the local has been checked out
    • Checkout as new local branch check out to local workspace and create new branch
    • Compare two branches to compare, for example, I want to compare the current Test branch with the local master branch, I will see

You will see a list of the changes you have submitted in one by one. Note that there is no part of the local repository that the changes made locally have not yet been committed to, that is, no commit.

    • Merge to compare versions into the current version, the merge process may have conflicts (remember that conflicts can occur when multiple people modify the same code), and then explain how to handle conflicts
    • Delete Deletes the current branch

Ok,branches panel introduced, of course, can also be in the bottom right corner of the same branches panel operation entrance, as follows--

Continue to introduce, warehouse level II navigation--

Tag Dozen Tagmerge Changes merge operation stash changes stash operation, concrete usage, if you do not know, you can refer to the following article ...

Here omit the rest of those operations, about the merge, stash, reset some of the operation details, need to understand the relevant parameters of the three commands the specific meaning, then go to the operation is very good understanding.

OK, about the right-click menu is introduced here, you can see what it can do-

1. It is very convenient to compare file or folder differences, trying to intuitively understand 2. Easy to do routine add/commit/revert operation, etc. 3. Easy to operate repository related management, such as fetch/merge/push/rebase, etc.

2.1 Version Control Panel

OK, Next, introduce the version Control Panel--

First, to introduce the corresponding local changes

Here is the diff file List of changes to the workspace and the current version, unversioned files, which means that there is no file list to be added to the version management, the add operation needs to be added to the buffer; The file in default is a file that is changed locally on behalf of version management , add and commit actions are required to add the changed files to the cache and submit them to the local repository. To know what git add and git commit do

Git add: Staging area's directory tree is updated, and the workspace modified (or added) file contents are written to a new object in the object library, and the ID of the object is recorded in the staging area file index. Git commit: The Staging area directory tree is written to the repository (object library) and the corresponding branch is updated accordingly. That is, the directory tree that the head points to is the staging area tree at commit time.

You can add to the new file, as follows--

The remaining options--

Revert: With the above narration, that is, restore local change move to another changelist: transfer to other change tags, categorize, good management show Diff: With the above-described jump to Source: Open the Change source file directly ignore: Join the. gitnore file in Create Patch: Change patch shelve changes: slightly similar to stash function, please refer to the article behind

Then, our most common operation is commit changes-

You can go to commit alone, and of course you can commit and push together.

As you can see, the local changes here also acts as a "git status" command.

OK, go ahead and introduce the log panel--

Select the appropriate branch, right-click, we see--

We see that the general options, as mentioned above, are not verbose here, Cherry-pick, refers to the change of the selected version of the file content merge into the current workspace, we will see, there will also be conflicting situation--

When we select the merge operation, we see such as-

Although the conflict of machine resolution is not very satisfying, but you can merge the result panel, directly to resolve the conflict, directly see the historical version, more intuitive.

After resolving the conflict, also let the need to do add and commit operations, as to how to use, mentioned above.

Next is the console panel, which is used to record all of the commands you have done with Git in Webstorm, as follows--

See, here's the command line, which is the usual command line we know.

The Version Control Panel is introduced here. As you can see, we use the version Control Panel, what we can do--

1. You can always see the list of locally changed files and content, easy to submit and restore 2. See all the branches (their own and small partners) dynamic, and corresponding changes to facilitate the comparison of documents, easy to trace the problem 3. You can reset or merge any version 4. You can also see the command line for any action, which facilitates learning the git command line

3. Advantages

Overall, individuals feel that webstorm operation git up, or very convenient, roughly divided into three categories--

1. Compare class Operation Compare2. Warehouse class Operation Repository3. Local operations locally changes

Personally think is also a very good learning context, overall, its greatest advantage is in a clear view.

4. Summary

At this point, the introduction of how to operate git webstorm, I am here, to give a most common git operation scenario, you can review the operation of the test-

General Cooperative Development (same branch development/different branch development): Add and Commit--fetch-> compare-> Merge (and resolve conflicts), push

From the touch git, to the git command line, to understanding how git works, and then to the deep use of Git, webstorm, you need to do it all-

1. Be familiar with Git's common theoretical knowledge 2. To familiarize yourself with the command line, if you're out of the IDE like Webstorm, you can do git version management 3. Take advantage of the view that the IDE brings clear this advantage, faster query problems, solve problems

OK, so far, Webstorm's research is temporarily over, recently engaged in other technical research ...

Reference:

0. JetBrains's introduction to version control

1. git staging Area understanding

2. git learning note 03--git Reset

3. Git Merge Merge partition detailed

4. git less pull multiple fetch and merge

5. summarize your git common commands

6. git uses the canonical process

7. git rebase subtotal (RPM)

8. Git Merge Merge partition detailed

9. git Book

Using Webstorm to manipulate git

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.