Use webstorm and git to develop node. js applications

Source: Internet
Author: User

Use webstorm and git to develop node. js applications

1. Use webstorm to create an express Project
1. Create a project
File | new project, first select location as D: \, enter the project name caller, and select the node. js Express project.
2. modify the configuration: Smart sensing
File | setting | JavaScript | node. js. Select only three ECMA scripts under the project directory, that is, JS support, and then select two node. js support options. Go to the public directory and enable DHTML and HTML5.
Note that multiple drop-down lists are available on the right of each line.

3. modify configuration: Run and debug
In the run menu, select Check no other instances are running in the run/debug configuration dialog box.
It indicates that other instances are running each time.
After this option is selected, the project will be re-run multiple times without errors.

Ii. Modify the Configuration:
1. Smart sensing
2. Git
3. Run debugging settings

3. Enable git source code management
1. Set the user name and email address
D: \> git config -- global user. Name Bi danjun
D: \> git config -- global user. Email 11084184@qq.com

2. Enable git source code management
VCs menu, enable Version Control Integration, and activate source code management integration. Select git.
The version control tab below shows that the following command is actually executed:
23:40:13. 651: cd d: \ caller
23:40:13. 652: git init
Initialized empty git repository in D:/caller/. Git/
After it is enabled, a new folder D: \ caller \ is created under the project folder \. git, which is the working folder of git. The project folder contains this folder, indicating that the project folder is managed by git as a whole.
3. Set which files and folders to ignore:
In the project folder, add a file named. gitignore file. This file tells git which content in the current folder needs to be ignored. The effect is obvious. After adding this file, unversioned files will be changed from 490 to 6, we excluded the webstorm project folder and npm_module folder.
Copy the following content (customized for the node. js project of webstorm:
*. Idea
. Idea
Idea
. Ds_store
*. Ds_store

Lib-cov
*. Seed
*. Log
*. CSV
*. Dat
*. Out
*. PID
*. GZ

PIDs
Logs
Results

Node_modules
Npm-debug.log

4. Add the current project to git
Initially, all files in the project folder were not added to the cache.
On the changes tab below, we can see that all the files in the folder are not added to the cache. Click click to browse to view all the files in the folder. Note the order: first select the project folder and then remove the npm_module directory. We do not add NPM to the source code library, which means that once the source code is obtained, you need to run the NPM install command in the project folder to add the corresponding dependency, or copy the npm_module folder of the Project dependency to the project folder, project can run normally.
Here you need to understand: local cache-> local source code library-> remote source code library, three levels. View the version control tab. We can see that the "add to cache" command is actually the GIT add command. The "prepare to submit to the local source code library" is added. Only git commit can be executed to truly put into the local source code library.

On the changes tab, right-click commit. At this time, the files in the cache area are actually stored in the local source code library.
5. On the changes Log tab, we can see the version history. We just submitted it once.
Select the submitted file, right-click it, and create tag. Let's make a tag: v0.01
Check out the version management console and actually run the command git tag v0.0.1 6db050e.

4. Local branches and development process:
Local git Branch:
1. Default Branch
Before the file is checked in, we can see branches in the lower right, with only one master branch. This branch is used as the place for release. In other words, every evolution of this branch is a release version of the project. We will create a develop branch, which is the Development Branch and the latest project status. Obviously, after the Development Branch stably implements the feature set of the released version, it can be merged into the master branch and tagged with version tags.
After the first check-in, we use it as version 0.01, and in the branches window, we can create a new branch.
2. Create a develop Branch
Actually, the following command is executed:
Git checkout-B develop
The current branch is the master, create a new branch (in the current branch status) develop, and then switch the current branch to the develop branch.
Of course, we do not work on the develop branch. Instead, we create a temporary branch and merge it to the develop branch. When the develop branch can be released as a version, a temporary release branch is created. after the work is completed, the Branch is merged back to the Development Branch, and then merged from the Development Branch to the master branch, with the version number tag.
Let's take a look at the bottom line of webstorm. On the right side, git: Develop is displayed, indicating that we are currently working in the develop branch. Click it to find that there is an additional local branch master, and we can switch over at any time.

In this example, create a branch with the goal of adding the readme. md file to an empty folder and name the branch as folder.
After checking in, merge it to the develop branch, and then delete the folder branch.
First, click git develop in the lower right corner to open the branches window. New Branch creates a new branch based on the current branch and name it folder. At this time, the current Branch switches to the folder branch.
Add readme. md to an empty folder. The prompt "add to version library" appears.
Then commit
Now the work is done.
Switch to the develop branch and we will find that the added files do not exist.
Select the folder branch in the branch window and select merge.
At this time, a message is displayed, indicating that the folder has been merged. A hyperlink of Delete folder is displayed. Click it to delete the folder branch.
Let's take a look. The current branch is develop, and all the files that have just been added have appeared.
This is a regular workflow.

5. Share it with GitHub
1. register an account on GitHub, which is assumed to be wflite
2. File-> setting-> GitHub change credentials and enter the user name and password.
3. Choose VCs> Import into version control> share project on GitHub.
Determine the remote repository name of GitHub as required, and enter the user name and password.
Now you have established an association with the GitHub project, you can push
4. VCs-> Git-> push
Push current branch to alternative branch is deselected by default, which means to push to the remote master. We need to create the develop branch in the remote database. Therefore, after switching to the develop branch locally, push again, if this option is selected, the develop branch is created in the remote database and the local branch and the remote branch with the same name are associated.
5. In the future, we will maintain synchronization between the local and GitHub develop branches. Only when a version is released will the local master Branch be pushed to the server master branch.

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.