JavaScript C++ Other
Latest commit 5c3b406 Feb 22, 2017 @implausible implausible committed on GitHub Merge pull request #1218 from implausible/feature/git_remote_ls
build safe convenience wrapper for git_remote_ls
Failed to load latest commit information.
.travis TravisCI: Create and push tags Nov 21, 2015
examples Provide target repository to write the index to Jan 29, 2017
generate Address PR concerns Feb 15, 2017
guides fix up electron and nw.js docs Sep 15, 2016
lib Address PR concerns Feb 15, 2017
lifecycleScripts Merge pull request #1186 from iloahz/master Jan 27, 2017
test remove destructuring Feb 15, 2017
utils fix linter and add nwjs equivalent Sep 15, 2016
vendor Merge pull request #1195 from implausible/feature/enable-curl-support Feb 6, 2017
.astylerc prettify generated output Nov 25, 2014
.editorconfig Added editor config Nov 24, 2014
.gitignore Generate script: write temp generated files to OS specific temp dir Jan 30, 2017
.gitmodules Add libgit2 as a submodule Apr 29, 2016
.jshintrc ES6 support for JSHint Apr 29, 2016
.npmignore Bring life cycle in line with npm standards Jun 14, 2016
.travis.yml Builds NodeGit on Node 7.4.0 Jan 29, 2017 Add header to separate v0.17 libgit2 changes vs NodeGit specific changes Feb 6, 2017 make generic and add Dec 5, 2014 Start up a FAQ Mar 22, 2016 fix a few things Nov 25, 2014
LICENSE Updated the license date and binding to latest. Apr 30, 2014 Bump to v0.17 Feb 6, 2017 Fix incorrect anchor link in Jan 3, 2017
appveyor.yml Builds NodeGit on Node 7.4.0 Jan 29, 2017
package.json Merge pull request #1091 from smith-kyle/improve-generate Feb 7, 2017


Node bindings to the libgit2 project.

Linux OS X Windows Coverage Dependencies
Coverage Status

Stable (libgit2#master): 0.17.0 Stable (libgit2@0.24): 0.14.1

Have a problem? Come chat with us!

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

Maintained by

Tim Branyen @tbranyen, John Haley @johnhaley81, and Max Korp @maxkorp with help from tons of awesome contributors!

Alumni Maintainers

Steve Smith @orderedlist, Michael Robinson @codeofinterest, and Nick Kallen @nk

API Documentation.

Getting started.

NodeGit will work on most systems out-of-the-box without any native dependencies.

npm install nodegit

If you receive errors about libstdc++, which are commonly experienced when building on Travis-CI, you can fix this by upgrading to the latest libstdc++-4.9.

In Ubuntu:

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install libstdc++-4.9-dev

In Travis:

      - ubuntu-toolchain-r-test
      - libstdc++-4.9-dev

In CircleCI:

      - sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
      - sudo apt-get update
      - sudo apt-get install -y libstdc++-4.9-dev

If you are still encountering problems while installing, you should try the Building from source instructions.

API examples.

Cloning a repository and reading a file:

var Git = require("nodegit");

// Clone a given repository into the `./tmp` folder.
Git.Clone("", "./tmp")
  // Look up this known commit.
  .then(function(repo) {
    // Use a known commit sha from this repository.
    return repo.getCommit("59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5");
  // Look up a specific file within that commit.
  .then(function(commit) {
    return commit.getEntry("");
  // Get the blob contents from the file.
  .then(function(entry) {
    // Patch the blob to contain a reference to the entry.
    return entry.getBlob().then(function(blob) {
      blob.entry = entry;
      return blob;
  // Display information about the blob.
  .then(function(blob) {
    // Show the path, sha, and filesize in bytes.
    console.log(blob.entry.path() + blob.entry.sha() + blob.rawsize() + "b");

    // Show a spacer.
    console.log(Array(72).join("=") + "\n\n");

    // Show the entire file.
  .catch(function(err) { console.log(err); });

Emulating git log:

var Git = require("nodegit");

// Open the repository directory."tmp")
  // Open the master branch.
  .then(function(repo) {
    return repo.getMasterCommit();
  // Display information about commits on master.
  .then(function(firstCommitOnMaster) {
    // Create a new history event emitter.
    var history = firstCommitOnMaster.history();

    // Create a counter to only show up to 9 entries.
    var count = 0;

    // Listen for commit events from the history.
    history.on("commit", function(commit) {
      // Disregard commits past 9.
      if (++count >= 9) {

      // Show the commit sha.
      console.log("commit " + commit.sha());

      // Store the author object.
      var author =;

      // Display author information.
      console.log("Author:\t" + + " <" + + ">");

      // Show the commit date.
      console.log("Date:\t" +;

      // Give some space and show the message.
      console.log("\n    " + commit.message());

    // Start emitting events.

For more examples, check the examples/ folder.

Unit tests.

You will need to build locally before running the tests. See above.

npm test