{"id":13819390,"url":"https://github.com/petersalomonsen/wasm-git","last_synced_at":"2026-01-31T17:17:31.386Z","repository":{"id":38368490,"uuid":"242495579","full_name":"petersalomonsen/wasm-git","owner":"petersalomonsen","description":"GIT for nodejs and the browser using https://libgit2.org compiled to WebAssembly with https://emscripten.org","archived":false,"fork":false,"pushed_at":"2024-08-21T06:14:41.000Z","size":159,"stargazers_count":704,"open_issues_count":22,"forks_count":41,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-24T10:45:17.223Z","etag":null,"topics":["emscripten","git","javascript","libgit2","nodejs","wasm","webassembly"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/petersalomonsen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["petersalomonsen"]}},"created_at":"2020-02-23T10:16:24.000Z","updated_at":"2025-04-22T01:04:31.000Z","dependencies_parsed_at":"2023-12-23T09:29:46.196Z","dependency_job_id":"57cc2cad-7bee-4002-ac3f-813c7e9eb867","html_url":"https://github.com/petersalomonsen/wasm-git","commit_stats":{"total_commits":37,"total_committers":6,"mean_commits":6.166666666666667,"dds":0.2702702702702703,"last_synced_commit":"b336ac60c226c10657d0e94da881916de5ef0877"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petersalomonsen%2Fwasm-git","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petersalomonsen%2Fwasm-git/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petersalomonsen%2Fwasm-git/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/petersalomonsen%2Fwasm-git/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/petersalomonsen","download_url":"https://codeload.github.com/petersalomonsen/wasm-git/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254470067,"owners_count":22076564,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emscripten","git","javascript","libgit2","nodejs","wasm","webassembly"],"created_at":"2024-08-04T08:00:46.705Z","updated_at":"2026-01-31T17:17:31.378Z","avatar_url":"https://github.com/petersalomonsen.png","language":"C","funding_links":["https://github.com/sponsors/petersalomonsen"],"categories":["C"],"sub_categories":[],"readme":"Wasm-git\n========\n(Wasm should be pronounced like `awesome` starting with a `W` ).\n\n![](https://github.com/petersalomonsen/wasm-git/actions/workflows/main.yml/badge.svg)\n\nGIT for nodejs and the browser using [libgit2](https://libgit2.org/) compiled to WebAssembly with [Emscripten](https://emscripten.org).\n\nThe main purpose of bringing git to the browser, is to enable storage of web application data locally in the users web browser, with the option to synchronize with a remote server.\n\n## Compatibility\n\n- **libgit2**: v1.7.1\n- **Emscripten**: Tested with 4.0.13 (compatible with 3.1.74+)\n- **Node.js**: v18+\n- **Browsers**: Modern browsers with WebAssembly support\n\n# Demo in the browser\n\nA simple demo in the browser can be found at:\n\nhttps://wasm-git.petersalomonsen.com/\n\n**Please do not abuse, this is open for you to test and see the proof of concept**\n\nThe sources for the demo can be found in the [githttpserver](https://github.com/petersalomonsen/githttpserver) project. It shows basic operations like cloning, edit files, add and commit, push and pull.\n\n# Demo videos\n\nVideos showing example applications using wasm-git can bee seen in [this playlist](https://www.youtube.com/watch?v=1Hqy7cVkygU\u0026list=PLv5wm4YuO4Iyx00ifs6xUwIRSFnBI8GZh). Wasm-git is used for local and offline storage of web application data, and for syncing with a remote server.\n\n# Examples\n\nWasm-git packages are built in two variants: Synchronuous and Asynchronuous. To run the sync version in the browser, a [webworker](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers) is needed. This is because of the use of synchronous http requests and long running operations that would block if running on the main thread. The sync version has the smallest binary, but need extra client code to communicate with the web worker. When using the sync version in nodejs [worker_threads](https://nodejs.org/api/worker_threads.html) are used, with [Atomics](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Atomics) to exchange data between threads.\n\nThe async version use [Emscripten Asyncify](https://emscripten.org/docs/porting/asyncify.html), which allows calling the Wasm-git functions with `async` / `await`. It can also run from the main thread in the browser. Asyncify increase the binary size because of instrumentation to unwind and rewind WebAssembly state, but makes it possible to have simple client code without exchanging data with worker threads like in the sync version.\n\nExamples of using Wasm-git can be found in the tests:\n\n- [test](./test/) for NodeJS\n- [test-browser](./test-browser/) for the sync version in the browser with a web worker\n- [test-browser-async](./test-browser-async/) for the async version in the browser\n\nThe examples shows importing the `lg2.js` / `lg2-async.js` modules from the local build, but you may also access these from releases available at public CDNs.\n\n# Building and developing\n\n## Prerequisites\n\n- [Emscripten SDK](https://emscripten.org/docs/getting_started/downloads.html) (tested with version 4.0.13)\n- Node.js (v18 or higher)\n- CMake\n- Make\n\n## Quick Start\n\n1. **Clone the repository**\n   ```bash\n   git clone https://github.com/petersalomonsen/wasm-git.git\n   cd wasm-git\n   ```\n\n2. **Install and activate Emscripten**\n   ```bash\n   git clone https://github.com/emscripten-core/emsdk.git\n   cd emsdk\n   ./emsdk install latest\n   ./emsdk activate latest\n   source ./emsdk_env.sh\n   cd ..\n   ```\n\n3. **Set up libgit2**\n   ```bash\n   ./setup.sh\n   ```\n   This script downloads libgit2 v1.7.1 and applies necessary patches for WebAssembly compilation.\n\n4. **Build the project**\n   ```bash\n   cd emscriptenbuild\n   ./build.sh         # Debug build (smaller, for development)\n   ./build.sh Release # Release build (optimized)\n   ```\n\n   For async versions (with Asyncify support):\n   ```bash\n   ./build.sh Debug-async   # Debug async build\n   ./build.sh Release-async # Release async build\n   ```\n\n5. **Install npm dependencies**\n   ```bash\n   npm install\n   ```\n\n6. **Run tests**\n   ```bash\n   npm test                  # Run Node.js tests\n   npm run test-browser      # Run browser tests (sync version)\n   npm run test-browser-async # Run browser tests (async version)\n   ```\n\n## Development Options\n\n### GitHub Codespaces\n\nThe easiest way to get started is using GitHub Codespaces. The repository includes a [.devcontainer](./.devcontainer) configuration that automatically sets up the complete development environment with all dependencies.\n\n### Local Development\n\nThe [Github actions test pipeline](./.github/workflows/main.yml) shows all the commands needed for CI/CD and can be used as a reference for local setup.\n\n## Build Outputs\n\nAfter building, you'll find the following files in `emscriptenbuild/libgit2/examples/`:\n- `lg2.js` and `lg2.wasm` - Synchronous version\n- `lg2_async.js` and `lg2_async.wasm` - Asynchronous version with Asyncify\n\nThese files are also available from npm packages and CDNs for production use.\n\n## Test Status\n\nAll tests are currently passing:\n- ✅ Node.js tests: 6/6 passing\n- ✅ Browser tests (sync): 18/18 passing\n- ✅ Browser async tests: Should work similarly to sync version\n\n## Troubleshooting\n\n### Common Issues\n\n1. **`writeArrayToMemory` errors**: Make sure you're using a compatible Emscripten version (3.1.74+). The project has been updated to use `Module.HEAPU8.set()` instead.\n\n2. **Build errors**: Ensure Emscripten environment is properly activated:\n   ```bash\n   source /path/to/emsdk/emsdk_env.sh\n   ```\n\n3. **Test failures**: Remove any stale test directories before running tests:\n   ```bash\n   rm -rf nodefsclonetest\n   npm test\n   ```\n\n# Emscripten fixes that were needed for making Wasm-git work\n\nAs part of being able to compile libgit2 to WebAssembly and run it in a Javascript environment, some fixes to [Emscripten](https://emscripten.org/) were needed.\n\nHere are the Pull Requests that resolved the issues identified when the first version was developed:\n\n- https://github.com/emscripten-core/emscripten/pull/10095\n- https://github.com/emscripten-core/emscripten/pull/10526\n- https://github.com/emscripten-core/emscripten/pull/10782\n\nfor using with `NODEFS` you'll also need https://github.com/emscripten-core/emscripten/pull/10669\n\nAll of these pull requests are merged to emscripten master as of 2020-03-29.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetersalomonsen%2Fwasm-git","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpetersalomonsen%2Fwasm-git","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpetersalomonsen%2Fwasm-git/lists"}