Detailed explanation node.js quickly set up a Git server with Node-Git-Server

This article uses Node-Git-Server

1. Detecting local git version

The use of the package requires the machine to install Git on the machine, and Git The version is greater than or equal to 2.7:

   

2, using NPM mounting package
   
╭─Root @ lt / home / workspace ╰- # npm install node-git -Server / Home / Workspace └ – ┬ node-git-server@0.3.0 ├─┬ http-duplex@0.0.2 │ ├─- Duplex-pipe@0.0.2 │ └ – inherits@1.0.2 └─ ─ through@2.3.8npm WARN enoent ENOENT: no such file or directory, open ‘/home/workspace/package.json’npm WARN workspace No descriptionnpm WARN workspace No repository field.npm WARN workspace No README datanpm WARN workspace No license field.

There is a warning to ignore ~ ​​

3, write examle

CD. /NODE_MODULES / NODE-GIT-Server / Example /

Edit INDEX.JS
 Const Server = Require ('Node-Git-Server'); Const Repos = new server ('/ tmp / repos'); const port = process.env.port || 80; Repos.on (Push', (Push) => {Console.log ('Push' + Push.repo + '/' + push.commit + '(' + push.branch + '); push.accept ();}; repos.on (Fetch) => {Console.log (' Fetch '+ fetch.commit; fetch.accept ();}; repos.listen (port, () => {console.log (`Node-git-server running at http: // localhost: $ {port} `});   4, operation 

╭─Root @ lt / Home / Workspace / Node_Modules / Node-Git-Server / Example ╰- # node index.js node-git-server running at http: // localhost: 80

   5, test Git server 
Since my git server runs on Aliyun, and bind www.beautifulzzzz.com, I first build a git warehouse locally and push it to the cloud, and then CLONE is going down. Test:

It can be seen that the local Git warehouse is synchronized to the cloud and the ordinary git server. It is too simple to convenient! ! !

The same git clone is also relatively simple!

详解Node.js利用node-git-server快速搭建git服务器 6, the location of the cloud git warehouse

We specify the git warehouse in Index.js: const repos = new server (‘/ tmp / repos’)

详解Node.js利用node-git-server快速搭建git服务器 Log in to the remote server can be found in the / tmp / repos / directory where we synchronized Git warehouse: (whose Beep.git is one of PUSH)

╭─root @ lt / tmp / repos ╰─ # ls beautifulzzz.git beep.git

The above is all the contents of this article, I hope to everyone Learn help, I hope everyone will support TUMI clouds.

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment