git uploads files to GitHub and gulp for easy use

Source: Internet
Author: User

Git has two ways to submit the source code to github the first way to submit via address presented below is via SSH upload

Git uploads code to github using SSH
Git first generates a public and private key to add the public key to GitHub to save the private key locally
+ command: ' ssh-keygen-t RSA ' generated public key and private key file will be in the. SSH directory of the user directory.


Push the code to the server, you need to pull it first (pulling is to download the files from the GIT project remotely, and then merge the files with the local branch)

Git Pull and gitclone difference: git pull is not set by default, the origin of this variable, you must manually set the GIT remote add ... And the Git clone default Origin this variable exists

After pull if the remote code is in conflict with the local code, git merges the conflict first, and if it cannot be merged automatically, it is necessary for us to handle the conflict manually.

If you do not have a. git directory locally, you need to initialize it first.
Command: ' git pull [remote server address] [remote branch] '

Gh-pages Branch-Build a blog.
You need to upload your own blog's page code to the Gh-pages branch on GitHub.
You can then directly access the
URL form of access: [GitHub user name].github.io/[warehouse name]/[specific page]

Npm
Official website [https://www.npmjs.com]
Node Package Manager
Initialize: ' NPM init '
Install the specified package: ' npm install jquery--save '
Delete the specified package: ' npm remove jquery--save '
Download the file that installs the Dependencies property pair in Package.json: ' NPM install--production '

Browser-sync
Automatically refresh the browser after changing the code
Need to use NPM for global installation: ' NPM install Browser-sync-g ',-g for installation to global
Using: ' Browser-sync start--server--files './index.html,app.css,./css/*.css,*.* "'
-the--files parameter specifies the files to be monitored, followed by a comma-delimited file path with the files to be monitored.

Gulp
Website (http://www.gulpjs.com)
[Chinese web] (http://www.gulpjs.com.cn)

-Front-end automation build tool
JS compression, Var x,xname, confusing
Merge.
CSS Compression
HTML compression

First Step: Install Gulp

' NPM install-g gulp-cli ' must be guaranteed to be installed globally gulp

Step two: Perform ' NPM init-y ' initialization in the current folder

Step three: Install Gulp in the current folder: "NPM Install gulp--save-dev" Note the folder name cannot be gulp

Fourth step: Create a file named ' Gulpfile.js ' in this JS file to write Gulp

Fifth step: Run your own Gulp execution command "Gulp task Name" in cmd

For example:

Plugin Download method

' NPM install--save-dev gulp-uglify '

"NPM Install--save-dev Gulp-concat"

"NPM Install--save-dev gulp-htmlmin"

.......

It can be written in gulpfile.js.

//Get Gulp object
Var gulp =require ("Gulp");
Download JS compression hybrid plug-in
var uglify =require ("gulp-uglify");
Download the merge Code plugin
var concat =require ("Gulp-concat");
Download CSS Compression hybrid plug-in
var Cssnano = require ("Gulp-cssnano");
Download HTML compression plug-in
var htmlmin = require ("gulp-htmlmin")
//Create a JS task
Gulp.task ("JS", function () {
Gulp.src ([" Js.js "," Index.js "])
. Pipe (Concat (" All.js "))
. Pipe (Uglify ())
. Pipe (Gulp.dest ("./dist "))
});
Create a CSS task
gulp.task ("CSS", function () {
Gulp.src (["Css.css", "Index.css"])
. Pipe (Concat ("All.css"))
. Pipe (Cssnano ())
. Pipe (Gulp.dest ("./dist"))
})
//Create an HTML task
Gulp.task ("HTML", function () {
GULP.SRC ("index.html")
. Pipe (Htmlmin ({collapsewhitespace:true})) HTML method differs from the other two methods that require the parameter parameter value to be a Boolean value only
. PIPE ( Gulp.dest ("./dist")) Dist Directory
} after processing files)


The core is 5 methods
Task,gulp in the form of a task to achieve the function.
A task (' Task Name ', function () {
.....
});
-SRC
+ src ('./*.js ')
-Dest ('./minjs/')//Specifies the output path of the processed file.
-Watch ('./*.js ', [' Task Name 1 ', ' Task Name 2 ']);
-Run (' Task Name ');//perform the specified task.

-Compression of JS code gulp-uglify
-Merge the Code Gulp-concat
-Compression of CSS Gulp-cssnano
-Compression of HTML gulp-htmlmin

git uploads files to GitHub and gulp for easy use

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.