[ Web Proxy ]
URL:
Viewing: https://nodegit.org [Back]  [Original]

Install NodeGit

NodeGit [NodeGit]

Install NodeGit

NodeGit can be quickly and painlessly installed via NPM. For more comprehensive installation techniques, check out the Install Guides.

npm install nodegit

Compatibility

Operating systems

Node support


Getting Started

You simply need to require NodeGit in your project to start using it.

var Git = require("nodegit");

Clone a Repository

Lets learn how to clone a repository. Create a file named clone.js, and add the following code:

var Git = require("nodegit");

Git.Clone("https://github.com/nodegit/nodegit", "nodegit").then(function(repository) {
  // Work with the repository object here.
});

This will clone our repository into a folder named nodegit.

Open a Repository

Lets learn how to open a repository. Create a file named open.js, and add the following code:

var Git = require("nodegit");

var getMostRecentCommit = function(repository) {
  return repository.getBranchCommit("master");
};

var getCommitMessage = function(commit) {
  return commit.message();
};

Git.Repository.open("nodegit")
  .then(getMostRecentCommit)
  .then(getCommitMessage)
  .then(function(message) {
    console.log(message);
  });

This will open our cloned repository and read out the latest commits message from master.

Have a problem? Come chat with us!

Visit slack.libgit2.org to sign up, then join us in #nodegit.


Brought to you by

NodeGit is brought to you by the work of many contributors all over the globe. We are proud to be sponsored by the following companies to continue work on making NodeGit one of the best native node modules around!


NodeGit, along with this website, is open source. Its brought to you by a core team, and a marvelous group of contributors.

Follow us on Twitter: @NodeGit

Licenced under MIT.


Web Proxy Viewer  |  New URL  |  Original Page