js-git: a Git implementation in JavaScript for building your own Git tools
A JavaScript implementation of Git.
At a glance
- What is it?
- js-git is a collection of JavaScript modules for reading and writing Git objects in the browser or in Node.js. It does not ship a CLI, so you assemble the functionality you need by mixing modules into a plain object.
- Who is it for?
- Adopt js-git when you need to read or write Git objects inside a JavaScript runtime and are willing to assemble the storage and walker mixins yourself. Do not adopt it if you want a command-line Git replacement or a drop-in repository client with authentication and remote protocols handled for you: the README describes object-level APIs, and the repository does not document a CLI.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository last received commits 158 days ago.
- What is it written in?
- Mainly JavaScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.
Star history
- creationix/js-git3,839 ★ · -7
| Repository | 2026-09-24 | 2026-11-25 |
|---|---|---|
| creationix/js-git | 3.8k | 3.8k |
-7 Stars in the last 62 days, measured from the daily GitHub snapshot. Compare with other projects
Editorial analysis
What js-git solves, and who it is for
The README states the project is a collection of modules that helps in implementing git powered applications in JavaScript. The original purpose was to enable better developer tools for authoring code in restricted environments like ChromeBooks and tablets. That framing matters: js-git is not positioned as a Git client you run from a terminal, but as a library you embed inside a tool you are already building. The second stated use is using git as a database to replace SQL and no-SQL data stores in many applications. That is a different audience again, one that wants content-addressed storage with a commit history rather than a source control workflow. If you are writing an editor, a review interface, a documentation browser, or an offline-first app that needs versioned content, the object model js-git exposes is the relevant part. If you want to run git status from JavaScript, this is the wrong layer.
The mixin architecture: a plain object plus the capabilities you add
The usage pattern is unusual and worth understanding before anything else. You create a plain JavaScript object, then call modules that attach methods to it. The README's example starts with `var repo = {};` and then requires js-git/mixins/mem-db, create-tree, pack-ops, walkers, read-combiner and formats in turn, each one taking `repo` as its argument. Each mixin adds a documented set of methods: mem-db provides an in-memory storage backend with saveAs, loadAs, saveRaw and loadRaw; create-tree adds a high-level API for creating multiple git objects by path; pack-ops adds unpack and pack for packfile streams; walkers adds logWalk and treeWalk; read-combiner combines parallel requests for the same resource; formats relaxes the object interface so you can pass strings instead of binary buffers. Nothing is added that you did not ask for, which keeps the surface small but means there is no single documented entry point that gives you a complete repository. Data flows through storage backends: saveAs returns a hash, and loadAs takes a type and a hash and returns the value. That hash-in, hash-out shape is the core of the design, and it is why the same code can sit on top of an in-memory store, a packfile, or whatever backend you write.
Installing js-git and creating your first commit
The package is published as js-git, currently at version 0.7.8, under the MIT licence. It depends on bodec, culvert, git-sha1 and pako. There is no documented CLI and no documented global install, so the realistic path is adding it to a Node.js project and requiring the mixins you need. The test script in package.json runs each file matching test/test-* through node, which is a reasonable way to see the APIs exercised if the doc subfolder leaves a question open. Install it with npm:
npm install js-gitThe README's first example builds an in-memory repo by mixing storage and walker modules into an empty object. Copy this shape rather than expecting a constructor:
var modes = require('js-git/lib/modes');
var repo = {};
require('js-git/mixins/mem-db')(repo);
require('js-git/mixins/create-tree')(repo);
require('js-git/mixins/pack-ops')(repo);
require('js-git/mixins/walkers')(repo);
require('js-git/mixins/read-combiner')(repo);
require('js-git/mixins/formats')(repo);With that object in hand, the README shows creating a blob, a tree and a commit using saveAs. The formats mixin is what lets you pass a string for the blob and omit committer, date and parents from the commit:
var blobHash = yield repo.saveAs("blob", "Hello World\n");
var treeHash = yield repo.saveAs("tree", {
"greeting.txt": { mode: modes.file, hash: blobHash }
});
var commitHash = yield repo.saveAs("commit", {
author: { name: "Tim Caswell", email: "[email protected]" },
tree: treeHash,
message: "Test commit\n"
});Reading the data back means walking the same chain in reverse. You load the commit, read its tree field, then load the entry by name. The README notes that with the formats mixin you can request "text" or "array" instead of a raw blob, which is the difference between getting a buffer and getting something you can print or iterate directly.
Generators, callbacks, and the runtime constraint that follows
Every example in the README uses yield inside a generator function, and the text is explicit that this style requires ES6 generators. It states the feature is in stable Firefox, in stable Chrome behind a user-configurable flag, and in node.js 0.11.x or greater with a command-line flag. That sentence dates the documentation more than the code, but the constraint it describes is real: if your target environment cannot run generators, you either apply a source transform such as regenerator or fall back to callbacks. The callback path is not a second API. The README explains that if you do not pass a callback, the function returns a partially applied version of your call expecting just the callback, and it shows the implementation pattern for supporting both. That is a clean trick, and it means you can write ordinary node-style code against the same methods. The cost is that the partially applied form is easy to misread in a stack trace, and the README does not document which methods support which style beyond saying all js-git APIs support both.
Where js-git is the wrong tool
The README does not document authentication, remote protocol handling, merge conflict resolution, or a working directory. It describes object creation, object loading, walkers and a filesystem style interface. If your requirement is to clone a private repository over HTTPS with credentials, or to produce a merge result when two branches diverge, the documentation shows no path for that. The in-memory database in the first example is explicitly described as useful for testing the network operations or just getting to know the available APIs, which suggests the storage layer is a starting point rather than a production store. The walkers are described as linear: logWalk walks history as a linear stream and treeWalk walks the file tree as a depth-first linear stream. Linear history walking is a real simplification when a repository has merges. The README also does not document rollback, error recovery or transaction semantics for any storage backend, so durability guarantees are whatever your backend provides, not something js-git adds.
How it compares to isomorphic-git
isomorphic-git is the other name that comes up when people search for a JavaScript Git library, and the difference in approach is worth stating plainly. js-git exposes object-level primitives and expects you to compose them: you pick a storage backend, mix in the operations you need, and work with hashes and types directly. isomorphic-git is not described in this repository's documentation, so the comparison here is limited to what js-git's own README claims about itself: it is a collection of modules for implementing git powered applications, not a single cohesive client. If you want to call a small number of high-level functions and have the library decide how to talk to storage and remotes, js-git's mixin model will feel like extra assembly work. If you want to control the storage layer, replace it, or run without a filesystem, that same model is the reason to choose js-git.
Maintenance status, licence and upgrade cost
The repository is not archived, and the last push was on 2026-06-20. The repository has no published GitHub releases, and package.json pins the published version at 0.7.8, so version numbering is not a reliable signal of activity here. The dependency list is short and the major dependencies are declared with caret ranges: bodec ^0.1.0, culvert ^0.1.2, git-sha1 ^0.1.2, pako ^0.2.5. Those are pre-1.0 ranges, which means a minor bump in a dependency can change behaviour without a major version change in js-git itself. The MIT licence permits use, modification and redistribution with the licence text retained; it does not include a patent grant, and this is not legal advice. Upgrade cost is mostly about your own mixin choices: because the library is a set of modules rather than a monolith, an upgrade affects only the mixins you actually required, but it also means there is no changelog in the repository describing what changed between versions.
Editorial conclusion
Adopt js-git when you need to read or write Git objects inside a JavaScript runtime and are willing to assemble the storage and walker mixins yourself. Do not adopt it if you want a command-line Git replacement or a drop-in repository client with authentication and remote protocols handled for you: the README describes object-level APIs, and the repository does not document a CLI. Before committing to it, check the doc subfolder for the API you intend to call, confirm that the mixin you need exists in the mixins directory, and verify that your runtime supports ES6 generators or that you can apply a source transform such as regenerator.
Frequently asked questions
How do I install js-git?
Install it from npm with npm install js-git. The package is named js-git and its current published version in package.json is 0.7.8. There is no documented global install or CLI.
Is js-git a Git client I can run from the command line?
No. The README describes it as a collection of modules that helps in implementing git powered applications in JavaScript, and the usage examples build a repo object by mixing in storage and walker modules. There is no CLI documented in the repository.
What control-flow styles does js-git support?
The README says all js-git APIs support both generator-based yield style and node-style callbacks. If you do not pass a callback, the function returns a partially applied version of your call expecting just the callback.
What is the mem-db mixin in js-git used for?
It provides an in-memory storage backend with saveAs, loadAs, saveRaw and loadRaw. The README describes the resulting in-memory git repo as useful for testing the network operations or just getting to know the available APIs.
How do I read a file out of a commit with js-git?
Load the commit with loadAs, read its tree field, then load the tree and use the entry hash for the file name. With the formats mixin you can request the blob as text or as an array instead of a raw binary buffer.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/creationix-js-git)Star history chart for your README
[](https://hysenlabs.com/projects/creationix-js-git)Was this useful?