Developing a node. js app using Webstorm and Git
I. Create an express project using Webstorm
1. Create a project
File|new project, select Location as D:\, enter the project name caller, and select the node. JS Express Project.
2. Modify the configuration: IntelliSense
File|setting|javascript|node.js, in the project directory, select only three ECMA script, which is JS support, and then select Two node. JS support. Move to the public directory to open DHTML, HTML5.
Note that the right side of each line is a multi-select drop-down box.
3. Modify configuration: Run and debug
Edit Configurations in the Run menu, in the Run/debug Configuration dialog box, tick Check no other instances is running
This means that each time you run it, check to see if there are other instances running.
After checking this, we re-run the project multiple times without error.
Second, modify the configuration:
1. Intelligent perception
2. Git
3. Run Debug settings
Third, enable Git source control
1. Set user name and email address
D:\>git config--global user.name Bi Danjun
D:\>git config--global user.email [email protected]
2. Enable Git source control
VCs menu, enable version control integration, activates source control integration. We choose Git.
As you can see in the Version Control tab below, you actually execute the following command:
23:40:13.651:CD D:\Caller
23:40:13.652:git Init
Initialized empty Git repository in d:/caller/.git/
When enabled, a new folder is created under the project folder D:\Caller\.git, which is the working folder for Git, which has this folder under the project folder, which indicates that the project folder is managed by Git.
3. Set which files and folders to ignore:
Under the project folder, add a file named. Gitignore, which will tell git what's in the current folder that needs to be ignored, and the effect is obvious, after joining this file, unversioned files changes from 490 to 6, We excluded the Webstorm project folder and the Npm_module folder.
Copy the following content (customized for Webstorm node. JS project):
*.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 buffer.
In the Changes tab below, we can see that all files in the folder are not added to the cache. Click to browse to view all the files on the folder, note the order: Tick the project folder first, then remove the Npm_module directory. We do not add NPM to the repository, which means that once you get the source code, you need to either add a dependency by running the NPM Install command under the project folder, or copy the project-dependent Npm_module folder to the project folder for the project to function properly.
Here's what you need to understand: local Cache--local source repository--Remote source library, three levels. We look at the Version Control tab and see that the join cache is actually a git add command, and add comes in "ready to commit to the local repository", and only executes git commit to actually put it on the local source repository.
On the Changes tab, right-click Commit. Then the cache files are actually deposited into the local source repository.
5, we in changes log label, see version history, just submitted once.
Check just the Commit, right click, Create tag, we do a tag: V0.01
Look at the version management console and actually run the command git tag V0.0.1 6db050e
Four, local branch and development process:
Local git branch:
1, default branch
before checking in the file, we can see branches in the lower right, with only one master branch. This branch, we will be the place of release, in other words, each evolution of this branch is a release version of the project. We will create a develop branch, which is the development branch, the latest state of the project, it is clear that the development branch is stable after the release version of the feature set, can be merged into the master branch and version tag.
After the first check-in, we use it as version 0.01, and in the branches window, we can create a new branch.
2, creating a develop branch
actually executes the following command:
git checkout-b develop
The current branch is master, creating a new branch (in the state of the current branch) develop, Then switch the current branch to the develop branch.
Of course, instead of working on the develop branch, we create a temporary branch and merge it into the develop branch at the beginning of each work. When the develop branch can be released as a version, create a temporary publishing branch, merge back into the development branch after the work is complete, and then merge the development branch into the master branch with the version number tag.
Let's look at the bottom row of webstorm, right, and show git:develop, which means we're currently working on the Develop branch. Click on it, you can find a local branch master, we can switch the past at any time.
So let's rehearse here, first create a branch, the target is the empty folder, add the readme.md file, the branch is named folder
When you are done, check in, then merge to the develop branch, and then delete the folder branch.
First, at the bottom right click on git develop, open the branches window, new branch based on the current branch to create a branch, named folder, when the current branch switch to the folder branch.
In the empty folder, add the Readme.md, will appear to join the repository prompt, join.
Then commit
The work is done now.
We switch to the develop branch, and we'll find that the few files that were added to the drop are not there.
Then select the folder branch in the Branch window and merge with merge.
You will be prompted to merge and give the Delete folder a hyperlink, click it, and the folder branch is deleted.
Look again, the current branch is develop, and the files that have just been added appear.
This is the usual workflow.
V. Share to GitHub
1. Register an account on GitHub, assuming Wflite
2, File->setting->github change credentials, enter the user name and password.
3. Vcs->import into version Control->share project on GitHub
On request, determine the remote library name for GitHub and enter a user name and password.
At this point, the connection to the GitHub project is established and you can push
4, Vcs->git->push
Push current branch to alternative branch is unchecked by default, indicating push to remote master, we have to establish a develop branch in the remote library, so after switching locally to the develop branch, push again, Checking this option will also set up the develop branch in the remote library and associate the local branch with the remote branch of the same name.
5. In the future, we will maintain local synchronization with GitHub's develop branch and push the local master branch to the server Master branch when a version is released.
Developing a node. js app using Webstorm and Git