Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork435
A pure JavaScript implementation of git for node and browsers!
License
isomorphic-git/isomorphic-git
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
isomorphic-git is a pure JavaScript reimplementation of git that works in both Node.js and browser JavaScript environments. It can read and write to git repositories, fetch from and push to git remotes (such as GitHub), all without any native C++ module dependencies.
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 includedisogit CLI can operate on git repositories on your desktop or server.
This library aims to be a complete solution with no assembly required.The API has been designed with modern tools like Rollup and Webpack in mind.By providing functionality as individual functions, code bundlers can produce smaller bundles by including only the functions your application uses.
The project includes type definitions so you can enjoy static type-checking and intelligent code completion in editors like VS Code andCodeSandbox.
The original author of the project (Billie Hilton) left the project, but the project is still maintained by two volunteers:
- @jcubic (most active)
- @mojavelinux
But they don't write much code, mainly do code review and try to answer to issues and on Gitter, they just don't want the project to die. So you can say that this project is community driven (as jcubic always reply to issues). Which means that if you want a feature to be implemented you need to do this yourself or find someone that is willing to write the code for you. The project have some money onOpenCollective and we can spend it on some development, if you find someone that is willing to code in exchange to some bucks (it may be you), but we don't have a lot so don't expect to have full sallary.
If you want to help this project you're more than welcome to do so.
The following environments are tested in CI and will continue to be supported until the next breaking version:
![]() Node 10 | Chrome 79 | Edge 79 | Firefox 72 | ![]() Safari 13 | Android 10 | iOS 13 |
See the fullRelease Notes on GitHub and the releaseBlog Post.
You can install it from npm:
npm install --save isomorphic-gitThe "isomorphic" inisomorphic-git means that the same code runs in either the server or the browser.That's tricky to do since git uses the file system and makes HTTP requests. Browsers don't have anfs module.And node and browsers have different APIs for making HTTP requests!
So rather than relying on thefs andhttp modules,isomorphic-git lets you bring your own file systemand HTTP client.
If you're usingisomorphic-git in node, you use the nativefs module and the provided node HTTP client.
// node.js exampleconstpath=require('path')constgit=require('isomorphic-git')consthttp=require('isomorphic-git/http/node')constfs=require('fs')constdir=path.join(process.cwd(),'test-clone')git.clone({ fs, http, dir,url:'https://github.com/isomorphic-git/lightning-fs'}).then(console.log)
If you're usingisomorphic-git in the browser, you'll need something that emulates thefs API.The easiest to setup and most performant library isLightningFS which is written and maintained by the same author and is part of theisomorphic-git suite.If LightningFS doesn't meet your requirements, isomorphic-git should also work withBrowserFS andFiler.Instead ofisomorphic-git/http/node this time importisomorphic-git/http/web:
<scriptsrc="https://unpkg.com/@isomorphic-git/lightning-fs"></script><scriptsrc="https://unpkg.com/isomorphic-git"></script><scripttype="module">importhttpfrom'https://unpkg.com/isomorphic-git@beta/http/web/index.js'constfs=newLightningFS('fs')constdir='/test-clone'git.clone({ fs, http, dir,url:'https://github.com/isomorphic-git/lightning-fs',corsProxy:'https://cors.isomorphic-git.org'}).then(console.log)</script>
If you're using ES module syntax, you can use either the default import for convenience, or named imports to benefit from tree-shaking if you are using a bundler:
importgitfrom'isomorphic-git'// orimport*asgitfrom'isomorphic-git'// orimport{plugins,clone,commit,push}from'isomorphic-git'
View the fullGetting Started guide on the docs website.
Then check out theUseful Snippets page, which includes even more sample code written by the community!
Unfortunately, due to the same-origin policy by defaultisomorphic-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 it ornpm install it. Alternatively, use CloudFlare workers, which can be setup without leaving the browser (instructions).
For testing or small projects, you can also usehttps://cors.isomorphic-git.org - a free proxy sponsored byClever Cloud.
We hope to get CORS headers added to all the major Git hosting platforms eventually, and will list the progress made here:
| Service | Supports CORS requests |
|---|---|
| Gogs (self-hosted) | ✔ |
| Gitea (self-hosted) | ✔ |
| Azure DevOps | ✔ (Usage Note: requires authentication) |
| Gitlab | ❌ OurPR was rejected, but theissue is still open! |
| Bitbucket | ❌ |
| Github | ❌ |
It is literally just two lines of code to add the CORS headers!! Easy stuff. Surely it will happen.
Isomorphic-git comes with a simple CLI tool, namedisogit becauseisomorphic-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 runany 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 usesminimisted 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 testingisomorphic-git and isn't really meant as agit CLI replacement.
This project follows semantic versioning, so we may continue to make changes to the API but they will always be backwards compatibleunless there is a major version bump.
- abortMerge
- add
- addNote
- addRemote
- annotatedTag
- branch
- checkout
- clone
- commit
- currentBranch
- deleteBranch
- deleteRef
- deleteRemote
- deleteTag
- expandOid
- expandRef
- fastForward
- fetch
- findMergeBase
- findRoot
- getConfig
- getConfigAll
- getRemoteInfo
- getRemoteInfo2
- hashBlob
- indexPack
- init
- isDescendent
- isIgnored
- listBranches
- listFiles
- listNotes
- listRefs
- listRemotes
- listServerRefs
- listTags
- log
- merge
- packObjects
- pull
- push
- readBlob
- readCommit
- readNote
- readObject
- readTag
- readTree
- remove
- removeNote
- renameBranch
- resetIndex
- resolveRef
- setConfig
- stash
- status
- statusMatrix
- tag
- updateIndex
- version
- walk
- writeBlob
- writeCommit
- writeObject
- writeRef
- writeTag
- writeTree
Share your questions and ideas with us! We love that.You can find us in ourGitter chatroom or just create an issue here on Github!We are also@IsomorphicGit on Twitter.
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'sJest for testing, which make doing TDD fast and fun,but we also used custom hacks so that the sametests will also run in the browser usingJasmine viaKarma.We even have our ownmock server for servinggit repository test fixtures!
You'll neednode.js installed, but everything else is a devDependency.
git clone https://github.com/isomorphic-git/isomorphic-gitcd isomorphic-gitnpm installnpmtest
Check out theCONTRIBUTING document for more instructions.
- nde - a futuristic next-generation web IDE
- git-app-manager - install "unhosted" websites locally by git cloning them
- GIT Web Terminal
- Next Editor
- Clever Cloud
- Stoplight Studio - a modern editor for API design and technical writing
Isomorphic-git would not have been possible without the pioneering work by@creationix and @chrisdickinson. Git is a tricky binary mess, and withouttheir examples (and their modules!) we would not have been able to come evenclose to finishing this. They are geniuses ahead of their time.
Cross-browser device testing is provided by:
Thanks goes to these wonderful people (emoji key):
This project follows theall-contributors specification. Contributions of any kind welcome!
Thank you to all our backers! 🙏 [Become a backer]
Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]
This work is released underThe MIT License
About
A pure JavaScript implementation of git for node and browsers!
Topics
Resources
License
Code of conduct
Contributing
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.



