[node. js] 2, using node-git-server to quickly build a git server

Source: Internet
Author: User

This article uses the Node-git-server

1. Detect local git version

The use of this package requires that Git be installed on the machine, and Git has a version greater than or equal to 2.7:

1 ╭─[email protected]/home/workspace  2 ╰─# git--version                                                                                                                                       129   ↵ 3 2.7. 4
2. Using NPM to install the package
1╭─[email protected]/home/Workspace2╰─# NPMInstallnode-git-Server3/home/Workspace4└─┬[email protected]0.3.0 5├─┬[email protected]0.0.2 6│├──[email protected]0.0.2 7│└──[email protected]1.0.2 8└──[email protected]2.3.8 9 TenNPM WARN enoent Enoent:no suchfileor directory, open'/home/workspace/package.json' One npm WARN Workspace No Description A npm WARN workspace No repository field. - npm WARN Workspace No README Data -NPM WARN workspace No license field.

A warning can be ignored first

3, write example

CD./node_modules/node-git-server/example/

Edit Index.js

1Const SERVER = require (' Node-git-server ');2Const REPOS =NewServer ('/tmp/repos ');3Const PORT = Process.env.PORT | | 80;4  5Repos.on (' push ', (push) = = {6Console.log (' push ' + Push.repo + '/' +Push.commit7+ ' (' + push.branch + ') '8     );9 push.accept ();Ten }); One   ARepos.on (' Fetch ', (fetch) = = { -Console.log (' fetch ' +fetch.commit); - fetch.accept (); the }); -   -Repos.listen (port, () = { -Console.log (' Node-git-server running at http://Localhost:${port} ') +});

4. Operation
1 ╭─[email protected]/home/workspace/node_modules/node-git-server/example  2   3 node-git-server running at http://localhost:80

5. Test the GIT server

Since my git server is running on Aliyun and bound to www.beautifulzzzz.com, I'm going to create a new git repository locally, push it to the cloud, and clone it to test:

There is no difference between synchronizing the local git repository to the cloud and the normal git server, which is simply too easy!!!

The same git clone is also relatively simple!

6, the location of the cloud Git warehouse

In Index.js we specify that the git repository is stored in: const REPOS = new Server ('/tmp/repos '); Directory under

Log on to the remote server to discover a git repository that we have synchronized in the/tmp/repos/directory: (where Beep.git is one of the previous push)

1 ╭─[email protected]/tmp/repos  2ls3 beautifulzzzz.git   Beep. Git

:: If you feel good, please recommend to more people to help them solve the problem in the pit of real problems faster!

@beautifulzzzz Intelligent Hardware, Internet of things, love technology, focus on products blog: http://blog.beautifulzzzz.com Group of Friends: 414948975

[node. js] 2, using node-git-server to quickly build a git server

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.