Skip to content

hdresearch/ziggit

Repository files navigation

ziggit

A modern git implementation written in pure Zig. Drop-in replacement for git — use ziggit wherever you'd use git.

4–10× faster than git on macOS arm64, compiles to a 142KB WebAssembly binary, and includes a succinct mode that cuts LLM token usage by 70–95%. Supports push/pull over HTTPS to GitHub and other git hosts. Includes a built-in git server (ziggit serve), delta encoding for efficient packs, and full shallow clone support.

Install

Homebrew (macOS / Linux)

brew tap hdresearch/tap
brew install ziggit

Download a release

Grab the latest binary for your platform from GitHub Releases:

macOS (Apple Silicon):

curl -fsSL https://github.com/hdresearch/ziggit/releases/latest/download/ziggit-macos-aarch64 -o ziggit
chmod +x ziggit
sudo mv ziggit /usr/local/bin/

macOS (Intel):

curl -fsSL https://github.com/hdresearch/ziggit/releases/latest/download/ziggit-macos-x86_64 -o ziggit
chmod +x ziggit
sudo mv ziggit /usr/local/bin/

Linux (x86_64):

curl -fsSL https://github.com/hdresearch/ziggit/releases/latest/download/ziggit-linux-x86_64 -o ziggit
chmod +x ziggit
sudo mv ziggit /usr/local/bin/

Linux (arm64):

curl -fsSL https://github.com/hdresearch/ziggit/releases/latest/download/ziggit-linux-aarch64 -o ziggit
chmod +x ziggit
sudo mv ziggit /usr/local/bin/

Alpine / musl (x86_64):

curl -fsSL https://github.com/hdresearch/ziggit/releases/latest/download/ziggit-linux-x86_64-musl -o ziggit
chmod +x ziggit
sudo mv ziggit /usr/local/bin/

Alpine / musl (arm64):

curl -fsSL https://github.com/hdresearch/ziggit/releases/latest/download/ziggit-linux-aarch64-musl -o ziggit
chmod +x ziggit
sudo mv ziggit /usr/local/bin/

Build from source

Requires Zig 0.15.2+.

git clone https://github.com/hdresearch/ziggit.git
cd ziggit
zig build -Doptimize=ReleaseFast
cp zig-out/bin/ziggit ~/.local/bin/

Alias as git

If you want to use ziggit as your default git:

alias git=ziggit

Add that to your ~/.bashrc, ~/.zshrc, or equivalent to make it permanent.

Usage

ziggit works exactly like git. Every command, flag, and argument you know works the same way:

ziggit init
ziggit clone https://github.com/user/repo.git
ziggit add .
ziggit commit -m "initial commit"
ziggit push origin main
ziggit log --oneline -10
ziggit status
ziggit diff
ziggit branch -a
ziggit checkout -b feature
ziggit stash
ziggit merge feature
ziggit rebase main
ziggit tag v1.0.0
ziggit blame README.md

It reads and writes the same .git directory format, so you can switch between git and ziggit freely on any repository.

Git server

ziggit includes a built-in pure-Zig git server that can serve git clone, git fetch, git pull, and git push from any standard git client:

ziggit serve --port=9418 --repo=/path/to/repo.git

The server implements both git-upload-pack (serving fetch/clone) and git-receive-pack (serving push) with full protocol support including capability negotiation, sideband communication, and delta-encoded pack streaming.

Delta encoding

Pack files generated by ziggit pack-objects use real delta compression. Objects of the same type are compared against recent candidates (configurable window), and deltas are emitted when they save significant space. This produces packs comparable in size to those from git and is used automatically during push operations.

Shallow clone support

Full shallow clone capabilities matching git:

ziggit clone --depth=1 https://github.com/user/repo.git        # shallow clone
ziggit fetch --deepen=5                                          # extend history by 5 commits
ziggit clone --shallow-since="2 weeks ago" https://github.com/user/repo.git  # date-based shallow

Supports deepen-since (timestamp-based shallow boundary) and deepen-relative (extend existing shallow boundary by N commits) for both protocol v1 and v2.

Succinct mode

Succinct mode compresses CLI output to save tokens when used by LLM coding agents. It's on by default.

Command Normal output Succinct output
status 12 lines with hints * main + Staged: 2 files ~ Modified: 1 files
log 6 lines per commit a1b2c3d fix: bug (2 min ago) Alice
commit [main a1b2c3d] msg + stats ok main a1b2c3d "msg"
checkout Switched to branch 'foo' ok switched to foo
push Progress + refs ok push main a1b2c3d
fetch Progress + ref updates ok fetch origin 3 refs
merge Verbose merge info ok merge feature
clone Counting, compressing, etc. ok clone URL
diff Full diff First 500 lines, then [full diff: git diff --no-succinct]

To disable succinct mode and get standard git output:

ziggit --no-succinct status

Or set the environment variable:

export GIT_SUCCINCT=0

Succinct mode automatically disables when running under git's test suite (GIT_TEST_INSTALLED), so it never interferes with compatibility testing.

Workflow commands

Three convenience commands for development loops:

ziggit restart              # fetch + rebase onto origin/main
ziggit start                # stash + restart + pop (safe restart with dirty tree)
ziggit progress "did stuff" # add -A + commit + push + restart

WebAssembly

ziggit compiles to a 142KB WASM binary (55KB gzipped) with 66 named exports — clone a repo in your browser. The WASM build uses pure-Zig zlib compression (no C dependencies), supporting full object storage and retrieval with proper deflate compression.

Build it:

zig build wasm

The output is at zig-out/wasm/ziggit.wasm. A ready-to-use demo is in the wasm/ directory — serve it with any static file server:

cd wasm
python3 -m http.server 8080

Then open http://localhost:8080/demo.html.

There is also a WASI build target for server-side WASM runtimes:

zig build -Dtarget=wasm32-wasi

Performance

Measured with hyperfine (100 runs, 5 warmup). Full details in BENCHMARKS.md.

CLI (macOS arm64)

Command git ziggit Speedup
status 8.1ms 1.0ms 8.1×
log -20 8.4ms 1.7ms 5.0×
branch -a 7.9ms 1.4ms 5.6×
blame (large repo) 36ms 2.8ms 12.6×

As a library (bun integration)

When used as a Zig library instead of spawning git as a subprocess:

Operation macOS arm64 Linux x86_64
findCommit (rev-parse) 85×
cloneBare 34×
Full workflow 10× 32×

Binary size

Target Size
macOS arm64 (ReleaseFast) 7.5MB
macOS arm64 (ReleaseSmall) 3.4MB
Linux x86_64 (stripped) 8.4MB
WASM (ReleaseSmall) 142KB
WASM (gzipped) 55KB

Testing

ziggit includes a libgit2-based cross-verification testing infrastructure for validating protocol correctness. The test/libgit2_server/ and test/libgit2_client/ directories contain C programs that test clone, fetch, and push operations against ziggit's server and vice versa, ensuring interoperability with independent git implementations. Protocol-level unit tests are in test/git_server_protocol_test.zig.

Git's official test suite is also used for compatibility testing — results are tracked in the test/git-test-results*.txt files.

Project structure

src/
  main.zig               # native entry point
  main_common.zig         # command dispatch (121 commands)
  main_freestanding.zig   # WASM entry point (freestanding)
  main_wasi.zig           # WASI entry point
  succinct.zig            # succinct output mode
  cmd_workflow.zig        # workflow commands (restart, start, progress)
  cmd_serve.zig           # git server command
  cmd_receive_pack.zig    # git-receive-pack implementation
  cmd_*.zig               # command implementations
  git/
    git_serve.zig         # git server protocol handler (upload-pack + receive-pack)
    git_storage.zig       # storage abstraction (filesystem + host-callback backends)
    delta_encode.zig      # delta compression for pack files
    smart_http.zig        # smart HTTP transport (clone, fetch, push)
    objects.zig           # object storage (with WASM-compatible zlib)
    ...                   # core git internals (refs, pack, index, etc.)
  platform/               # platform abstraction (native, WASM, WASI)
wasm/
  demo.html               # browser demo
  demo.js                 # WASM host bindings
  ziggit.wasm             # prebuilt WASM binary
test/
  libgit2_server/         # libgit2-based test server for cross-verification
  libgit2_client/         # libgit2-based test client for cross-verification
  git_server_protocol_test.zig  # server protocol unit tests
  delta_encode_test.zig   # delta encoding roundtrip tests
  git-test-results*.txt   # git official test suite results
build.zig

License

GPLv2

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages