You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Installation
$ npm install gitkit
Usage
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).
varGitKit=require('gitkit');varNativeFS=require('gitkit/lib/fs/native');// Prepare the filesystemvarfs=NativeFS(process.cwd());// Create a repository instancevarrepo=GitKit.Repository.createWithFS(fs,isBare);
Clone a remote repository
// Create a transport instance for the GitHub repositoryvartransport=newGitKit.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.
varauthor=GitKit.Person.create('Bob','bob@gmail.com');varmessage='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.
Thanks
To the people pointing me in the right directions like: