Node.js Adapter for js-git File System Access

1.0.0 · abandoned · verified Sun Apr 19

git-node-fs is a Node.js adapter designed to provide file system access for the deprecated `js-git` library. It enables `js-git` to interact with Git repositories directly on the local filesystem. The package's latest version, 1.0.0, was published over 10 years ago, indicating it is no longer actively maintained. Its core dependency, `js-git`, also appears to be unmaintained, making `git-node-fs` unsuitable for new projects or environments requiring modern Git features or security updates. Developers seeking current Git integration in Node.js should explore actively maintained alternatives such as `isomorphic-git` or `simple-git` which offer broader platform support (including browsers) and modern JavaScript features like Promises and ESM. The package provides a CommonJS interface for mixing file system capabilities into a `js-git` repository object.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to set up a `js-git` repository object with `git-node-fs` to enable local filesystem interaction for Git operations.

const path = require('node:path');
const fsAdapter = require('git-node-fs');

// Initialize a repository object (this is a js-git concept)
const repo = {};

// Point the repository to a .git directory
// For a non-bare repository, it would be the .git folder within the worktree.
// For a bare repository, it would be the bare repo directory itself.
repo.rootPath = path.join(__dirname, '.git');

// Mix in the filesystem database adapter from git-node-fs into the repo object
// This allows js-git operations to interact with the local filesystem.
require('js-git/mixins/fs-db')(repo, fsAdapter);

console.log('Repository configured for git-node-fs:');
console.log(repo);

// At this point, `repo` can be used with other js-git mixins to perform
// Git operations like reading commits, trees, blobs, etc.
// Example (requires more js-git setup):
// const { readCommit } = require('js-git/mixins/walkers')(repo);
// readCommit('HEAD', (err, commit) => {
//   if (err) { console.error('Error reading commit:', err); return; }
//   console.log('HEAD commit:', commit.short); // Assuming a 'short' property exists or similar.
// });

view raw JSON →