Pure javascript implementation of Git (Node.js and Browser)
Switch branches/tags
Nothing to show
Clone or download
Latest commit 277a149 Jun 26, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Rename bin gitkit Jun 19, 2016
examples Add example for cloning in readme Jun 19, 2016
lib Fix node fs mkdir Jun 26, 2016
testing Normalize all comments Jun 19, 2016
.eslintrc Fix some linting error Jun 19, 2016
.gitignore Add base test for repo initialiazation Apr 11, 2016
.travis.yml Base structure for eslint and travis testing Dec 17, 2015
CHANGES.md Bump version to 0.1.0 Jun 19, 2016
LICENSE Initial commit Dec 16, 2015
README.md svg badge Jun 22, 2016
appveyor.yml Add ci buttons Jun 19, 2016
package.json Implement MemoryFS for browsers Jun 20, 2016



NPM version Linux Build Status Windows Build status

Pure JavaScript implementation of Git backed by immutable models and promises.

The goal is to provide both a low and high level API for manipulating Git repositories: read files, commit changes, edit working index, clone, push, fetch, etc.

This library can work both in the browser and Node.js.


$ npm install gitkit


API Basics

State of the Git repository is represented as a single immutable Repository object. Read and write access to the repository is done using a FS driver, the implementation of the fs depends on the plaftrom (NativeFS for Node.js/Native, LocalStorageFS or MemoryFS for the browser).

var GitKit = require('gitkit');
var NativeFS = require('gitkit/lib/fs/native');

// Prepare the filesystem
var fs = NativeFS(process.cwd());

// Create a repository instance
var repo = GitKit.Repository.createWithFS(fs, isBare);
Clone a remote repository
// Create a transport instance for the GitHub repository
var transport = new GitKit.HTTPTransport('https://github.com/GitbookIO/gitbook.git');

GitKit.TransferUtils.clone(repo, transport)
.then(function(newRepo) {
    // Clone succeed!
}, function(err) {
    // Clone failed
List branches

GitKit.BranchUtils.list returns a promise listing branches as a list of strings.

    .then(function(branches) { ... })
Get current branch

GitKit.BranchUtils.getCurrent returns a promise resolved with the name of the current active branch.

    .then(function(branch) { ... })
List files in repository

GitKit.WorkingIndex provides a set of methods to work with the working index.

    .then(function(workingIndex) {
        var entries = workingIndex.getEntries();
List changes not staged for commit

GitKit.ChangesUtils provides a set of methods to work with pending changes.

    .then(function(changes) { ... });
Commit changes
var author = GitKit.Person.create('Bob', 'bob@gmail.com');
var message = 'My First commit';

GitKit.CommitUtils.createForChanges(repo, author, message, changes)
    .then(function(newRepo) { ... });
More example and documentation coming soon!

I'll publish a better documentation for this library soon.


To the people pointing me in the right directions like:


GitKit.js is Apache-licensed.