Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including isomorphic-git with all npm packages installed. Try it out:

var isomorphicGit = require("isomorphic-git")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

isomorphic-git v0.51.12

A pure JavaScript implementation of git for node and browsers!

isomorphic-git

A pure JavaScript implementation of git for node and browsers!

Latest release:

current npm version required node version written in ECMAScript 2017+ license gzip size install size

Master branch status:

semantic-release Build Status dependencies Known Vulnerabilities FOSSA Status

Social:

Gitter chat Backers on Open Collective Sponsors on Open Collective

Browser Support:

Sauce Labs Test Status (for master branch)

Most recent build:

Build Status Build Status BrowserStack Status

isomorphic-git is a pure JavaScript implementation of git that works in node and browser environments (including WebWorkers and ServiceWorkers). This means it can be used to read and write to git repositories, as well as fetch from and push to git remotes like Github.

Isomorphic-git aims for 100% interoperability with the canonical git implementation. This means it does all its operations by modifying files in a ".git" directory just like the git you are used to. The included isogit CLI can operate on git repositories on your desktop or server.

isomorphic-git aims to be a complete solution with no assembly required. I've tried carefully to design the API so it is easy to use all the features, without paying a penalty in bundle size. By providing functionality as separate functions instead of an object oriented API, code bundlers like Webpack will only include the functionality your application actually uses. (Or at least that's the goal.)

The project includes type definitions so you can enjoy static type-checking and intelligent code completion in editors like VS Code and CodeSandbox.

Getting Started

The "isomorphic" in isomorphic-git means it works equally well on the server or the browser. That's tricky to do since git uses the file system, and browsers don't have an fs module. So rather than relying on the fs module, isomorphic-git is BYOFS (Bring Your Own File System). Before you can use most isomorphic-git functions, you need to set the fs module via the plugin system.

If you're only using isomorphic-git in Node, you can just use the native fs module.

const git = require('isomorphic-git');
const fs = require('fs');
git.plugins.set('fs', fs)

If you're writing code for the browser though, you'll need something that emulates the fs API. At the time of writing, the most complete option is BrowserFS. Compared to Node, there is an extra setup step to configure BrowserFS, as seen below:

<script src="https://unpkg.com/browserfs"></script>
<script src="https://unpkg.com/isomorphic-git"></script>
<script>
BrowserFS.configure({ fs: "IndexedDB", options: {} }, function (err) {
  if (err) return console.log(err);
  window.fs = BrowserFS.BFSRequire("fs");
  git.plugins.set('fs', window.fs);
});
</script>

Besides IndexedDB, BrowserFS supports many different backends with different performance characteristics, as well as advanced configurations such as: multiple mounting points, and overlaying a writeable filesystem on top of a read-only filesystem. You don't need to know about all these features, but familiarizing yourself with the different options may be necessary if you hit a storage limit or performance bottleneck using the IndexedDB backend I suggested above.

View the full Getting Started guide on the docs website.

Then check out the Useful Snippets page, which includes even more sample code written by the community!

CORS support

Unfortunately, due to the same-origin policy by default isomorphic-git can only clone from the same origin as the webpage it is running on. This is terribly inconvenient, as it means for all practical purposes cloning and pushing repos must be done through a proxy.

For this purpose @isomorphic-git/cors-proxy exists which you can clone or npm install. For testing or small projects, you can also use https://cors.isomorphic-git.org - a free proxy sponsored by Clever Cloud.

I'm hoping to get CORS headers added to all the major Git hosting platforms eventually, and will list my progress here:

ServiceSupports CORS requests
Gogs (self-hosted)
Gitea (self-hosted)
Azure DevOps (Usage Note: requires noGitSuffix: true and authentication)
Gitlab❌ My PR was rejected, but the issue is still open!
Bitbucket
Github

It is literally just two lines of code to add the CORS headers!! Easy stuff. Surely it will happen.

Using as an npm module

You can install it from npm.

npm install --save isomorphic-git

In the package.json you'll see there are actually 4 different versions:

  "main": "dist/for-node/isomorphic-git/index.js",
  "module": "dist/for-future/isomorphic-git/index.js",
  "unpkg": "dist/bundle.umd.min.js",

This deserves a brief explanation.

  • the "main" version is for node.
  • the "module" version is for webpack or other browser bundlers.
  • the "unpkg" version is the UMD build.

isogit CLI

Isomorphic-git comes with a simple CLI tool, named isogit because isomorphic-git is a lot to type. It is really just a thin shell that translates command line arguments into the equivalent JS API commands. So you should be able to run any current or future isomorphic-git commands using the CLI.

It always starts with an the assumption that the current working directory is a git root. E.g. { dir: '.' }.

It uses minimisted to parse command line options and will print out the equivalent JS command and pretty-print the output JSON.

The CLI is more of a lark for quickly testing isomorphic-git and isn't really meant as a git CLI replacement.

Supported Git commands

This project follows semantic versioning, so I may continue to make changes to the API but they will always be backwards compatible unless there is a major version bump.

commands

plugins

Community

Share your questions and ideas with us! We love that. You can find us in our Gitter chatroom or just create an issue here on Github! We are also @IsomorphicGit on Twitter.

Contributing to isomorphic-git

The development setup is similar to that of a large web application. The main difference is the ridiculous amount of hacks involved in the tests. We use Facebook's Jest for testing, which make doing TDD fast and fun, but we also used custom hacks so that the same tests will also run in the browser using Jasmine via Karma. We even have our own karma plugin for serving git repository test fixtures!

You'll need Node.js installed, but everything else is a devDependency.

git clone https://github.com/isomorphic-git/isomorphic-git
cd isomorphic-git
npm install
npm test

Check out the CONTRIBUTING document for more instructions.

Who is using isomorphic-git?

Similar projects

Acknowledgments

Isomorphic-git would not have been possible without the pioneering work by @creationix and @chrisdickinson. Git is a tricky binary mess, and without their examples (and their modules!) I would not have been able to come even close to finishing this. They are geniuses ahead of their time.

Cross-browser device testing is provided by:

BrowserStack

SauceLabs

Contributors

Thanks goes to these wonderful people (emoji key):

| [
William Hilton](https://onename.com/wmhilton)
[📝](#blog-wmhilton "Blogposts") [🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Awmhilton "Bug reports") [💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=wmhilton "Code") [🎨](#design-wmhilton "Design") [📖](https://github.com/isomorphic-git/isomorphic-git/commits?author=wmhilton "Documentation") [💡](#example-wmhilton "Examples") [⚠️](https://github.com/isomorphic-git/isomorphic-git/commits?author=wmhilton "Tests") [✅](#tutorial-wmhilton "Tutorials") | [
wDhTIG](https://github.com/wDhTIG)
[🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3AwDhTIG "Bug reports") | [
Marc MacLeod](https://github.com/marbemac)
[🤔](#ideas-marbemac "Ideas, Planning, & Feedback") [🔍](#fundingFinding-marbemac "Funding Finding") | [
Brett Zamir](http://brett-zamir.me)
[🤔](#ideas-brettz9 "Ideas, Planning, & Feedback") | [
Dan Allen](http://mojavelinux.com)
[🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Amojavelinux "Bug reports") [💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=mojavelinux "Code") [🤔](#ideas-mojavelinux "Ideas, Planning, & Feedback") | [
Tomáš Hübelbauer](https://TomasHubelbauer.net)
[🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3ATomasHubelbauer "Bug reports") [💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=TomasHubelbauer "Code") | [
Juan Campa](https://github.com/juancampa)
[🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Ajuancampa "Bug reports") [💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=juancampa "Code") | | :---: | :---: | :---: | :---: | :---: | :---: | :---: | | [
Ira Miller](http://iramiller.com)
[🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Aisysd "Bug reports") | [
Rhys Arkins](http://rhys.arkins.net)
[💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=rarkins "Code") | [
Sean Larkin](http://twitter.com/TheLarkInn)
[💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=TheLarkInn "Code") | [
Daniel Ruf](https://daniel-ruf.de)
[💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=DanielRuf "Code") | [
bokuweb](http://blog.bokuweb.me/)
[💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=bokuweb "Code") [📖](https://github.com/isomorphic-git/isomorphic-git/commits?author=bokuweb "Documentation") [⚠️](https://github.com/isomorphic-git/isomorphic-git/commits?author=bokuweb "Tests") | [
Hiroki Osame](https://github.com/hirokiosame)
[💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=hirokiosame "Code") [📖](https://github.com/isomorphic-git/isomorphic-git/commits?author=hirokiosame "Documentation") | [
Jakub Jankiewicz](http://jcubic.pl/me)
[💬](#question-jcubic "Answering Questions") [🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Ajcubic "Bug reports") [💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=jcubic "Code") [💡](#example-jcubic "Examples") [⚠️](https://github.com/isomorphic-git/isomorphic-git/commits?author=jcubic "Tests") | | [
howardgod](https://github.com/howardgod)
[🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Ahowardgod "Bug reports") [💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=howardgod "Code") | [
burningTyger](https://twitter.com/btyga)
[🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3AburningTyger "Bug reports") | [
Melvin Carvalho](https://melvincarvalho.com/#me)
[📖](https://github.com/isomorphic-git/isomorphic-git/commits?author=melvincarvalho "Documentation") |
akaJes
[💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=akaJes "Code") | [
Dima Sabanin](http://twitter.com/dimasabanin)
[🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Adsabanin "Bug reports") [💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=dsabanin "Code") | [
Koutaro Chikuba](http://twitter.com/mizchi)
[🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Amizchi "Bug reports") [💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=mizchi "Code") | [
Hubert SABLONNIÈRE](https://www.hsablonniere.com/)
[💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=hsablonniere "Code") [⚠️](https://github.com/isomorphic-git/isomorphic-git/commits?author=hsablonniere "Tests") [🤔](#ideas-hsablonniere "Ideas, Planning, & Feedback") [🔍](#fundingFinding-hsablonniere "Funding Finding") | | [
David Duarte](https://github.com/DeltaEvo)
[💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=DeltaEvo "Code") | [
Thomas Pytleski](http://stoplight.io/)
[🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Apytlesk4 "Bug reports") [💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=pytlesk4 "Code") | [
Vadim Markovtsev](http://linkedin.com/in/vmarkovtsev)
[🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Avmarkovtsev "Bug reports") | [
Yu Shimura](https://yuhr.org)
[🤔](#ideas-yuhr "Ideas, Planning, & Feedback") [💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=yuhr "Code") [⚠️](https://github.com/isomorphic-git/isomorphic-git/commits?author=yuhr "Tests") | [
Dan Lynch](https://github.com/pyramation)
[💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=pyramation "Code") | [
Jeffrey Wescott](https://www.jeffreywescott.com/)
[🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Ajeffreywescott "Bug reports") [💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=jeffreywescott "Code") | [
zebzhao](https://github.com/zebzhao)
[💻](https://github.com/isomorphic-git/isomorphic-git/commits?author=zebzhao "Code") | | [
Tyler Smith](https://github.com/tilersmyth)
[🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Atilersmyth "Bug reports") | [
Bram Borggreve](https://github.com/beeman)
[🐛](https://github.com/isomorphic-git/isomorphic-git/issues?q=author%3Abeeman "Bug reports") |

This project follows the all-contributors specification. Contributions of any kind welcome!

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free