This is @readme/nodegit, a fork of the original NodeGit library that provides Node.js bindings to libgit2. This fork is maintained by Readme and includes compatibility updates for Node.js 20 and 22.
- Node.js >= 20 (supports Node 20 and 22)
- Git installed on your system
- Build tools (automatically handled during install)
npm installThe install process automatically:
- Runs preinstall scripts
- Builds native bindings using node-gyp
- Runs postinstall scripts
npm testThis runs linting followed by the complete test suite.
npm run mochanpm run mochaDebugRuns tests with inspector for debugging.
# Run tests matching a pattern
npm run mocha -- --grep "pattern"
# Example: Run only commit tests
npm run mocha -- --grep "commit"
# Example: Run a specific test
npm run mocha -- --grep "can amend commit"npm run lint# Full rebuild (includes code generation)
npm run rebuild
# Debug build
npm run rebuildDebug
# Recompile only (skip code generation)
npm run recompile# Generate missing tests
npm run generateMissingTests
# Generate native code bindings
npm run generateNativeCode
# Generate JSON API definitions
npm run generateJsonTests are located in:
test/tests/- Main test filestest/utils/- Test utilitiestest/repos/- Test repositories
macOS Version Compatibility: Tests may fail when upgrading macOS versions due to differences in Git behavior, file system precision, or system libraries. Hardcoded expected commit IDs are particularly sensitive to environment changes.
Memory Management: Tests use --expose-gc flag to test garbage collection behavior with native bindings.
SSH Tests: Some tests require SSH keys located in test/id_rsa* files.
GitHub Actions workflows:
- tests.yml: Runs tests on Ubuntu 22.04 and macOS-26
- publish.yml: Handles package publishing
This library provides JavaScript bindings to the libgit2 C library:
src/- C++ binding codelib/- Generated JavaScript APIsgenerate/- Code generation scriptsinclude/- C++ headersvendor/- Vendored dependencies (libgit2)
# Clean rebuild
rm -rf build node_modules
npm install- Check that Git is properly configured:
git config --global user.name "Test User" git config --global user.email "test@example.com"
- Ensure SSH agent is running for SSH tests
- Linux: May require libssl-dev, libkrb5-dev, and pcre development packages
- macOS: Uses clang compiler, may require Xcode command line tools
- Windows: Requires Visual Studio build tools
- Run tests locally:
npm test - Ensure linting passes:
npm run lint - Test on target Node versions (20, 22)
- Update tests if adding new functionality
For more detailed API documentation, visit nodegit.org.