Git implementation in MoonBit with practical compatibility extensions.
Warning: This is an experimental implementation. Do not use in production. Data corruption may occur in worst case scenarios. Always keep backups of important repositories.
Supported platforms: Linux x64, macOS arm64/x64
# One-line install
curl -fsSL https://raw.githubusercontent.com/mizchi/bit-vcs/main/install.sh | bash
# Or install via MoonBit toolchain
moon install mizchi/bit/cmd/bit# bash (~/.bashrc)
eval "$(bit completion bash)"
# zsh (~/.zshrc)
eval "$(bit completion zsh)"bit clone https://github.com/user/repo
bit checkout -b feature
bit add .
bit commit -m "changes"
bit push origin featurebit fingerprint is currently a feature set (workspace/hub integration), not a standalone top-level command.
# Workspace flow uses per-node directory fingerprints
BIT_WORKSPACE_FINGERPRINT_MODE=git bit workspace flow test
BIT_WORKSPACE_FINGERPRINT_MODE=fast bit workspace flow test
# Hub workflow records can carry a workspace fingerprint
bit hub pr workflow submit 123 \
--task test --status success \
--fingerprint <workspace-fingerprint> \
--txn <txn-id>Use bit subdir-clone (or clone shorthand) to work on a repository subdirectory as an independent repo.
# Explicit command
bit subdir-clone https://github.com/user/repo src/lib mylib
# Shorthand via clone
bit clone user/repo:src/lib
bit clone user/repo@main:src/lib
# GitHub tree/blob URL is also supported
bit clone https://github.com/user/repo/tree/main/packages/core
bit clone https://github.com/user/repo/blob/main/README.mdCloned subdirectories have their own .git directory. When placed inside another git repository, git treats them as embedded repositories (similar to submodules), and the parent repo does not commit their contents.
Git-native PR/Issue workflow stored in repository data.
bit hub init
# PR / Issue
bit hub pr list --open
bit hub issue list --open
# Sync metadata
bit hub sync push
bit hub sync fetch
# Search
bit hub search "cache" --type pr --state open
# Shortcuts
bit pr list --open
bit issue list --openAI-assisted rebase conflict resolution (OpenRouter, default model moonshotai/kimi-k2).
Subcommands:
rebase(alias:rebase-ai)mergecommitcherry-pickrevert
export OPENROUTER_API_KEY=...
# Start / continue / abort / skip
bit ai rebase main
bit ai rebase --continue
bit ai rebase --abort
bit ai rebase --skip
bit ai merge --continue
bit ai merge --abort
# Options
bit ai rebase --model moonshotai/kimi-k2 --max-ai-rounds 16 main
bit ai rebase --agent-loop --agent-max-steps 24 main
bit ai merge --agent-loop --agent-max-steps 24 branch
bit ai commit --split
bit ai commit
bit ai cherry-pick abc1234
bit ai revert abc1234
# Alias (legacy)
bit rebase-ai mainExperimental AI-assisted commit message helper entrypoint (currently delegates to bit commit for compatibility).
bit ai commit は rebase と同じ AI 設定引数を受け付けます(--model, --max-ai-rounds, --agent-loop, --agent-max-steps)。
bit ai commit -m "message..."
bit ai commitStart the MCP server via bit mcp (native target).
# Start MCP server (stdio)
bit mcp
# Help
bit mcp --help
bit help mcp
# Standalone MoonBit entrypoint (equivalent server implementation)
moon run src/x/mcp --target nativeghq-compatible repository manager (default root: ~/bhq).
bit hq get mizchi/git
bit hq get -u mizchi/git
bit hq get --shallow mizchi/git
bit hq list
bit hq list mizchi
bit hq rootbit core operations can run against any storage backend that implements:
@bit.FileSystem(write side)@bit.RepoFileSystem(read side)
Entry point:
/Users/mz/ghq/github.com/mizchi/bit/src/cmd/bit/storage_runtime.mbtrun_storage_command(fs, rfs, root, cmd, args)
One in-memory implementation is @bit.TestFs, which can be used as agent storage:
let fs = @bit.TestFs::new()
let root = "/agent-repo"
run_storage_command(fs, fs, root, "init", ["-q"])
fs.write_string(root + "/note.txt", "hello")
run_storage_command(fs, fs, root, "add", ["note.txt"])
run_storage_command(fs, fs, root, "commit", ["-m", "agent snapshot"])- Git config: reads global aliases from
~/.gitconfig(orGIT_CONFIG_GLOBAL) only. - Generic
filter=attributes (clean/smudge) are handled natively. - Detailed standalone scope, unsupported paths, fallback points, and git/t coverage are documented in
docs/git-compatibility.md.
The following features are not supported and will produce a fatal error:
Repository formats
- SHA-256 repositories (
--object-format=sha256) - Reftable ref format (
--ref-format=reftable) - Incremental multi-pack-index chains
Gitattributes
filter=lfs(Git LFS)working-tree-encoding=
Commit & rebase
- Signed commits (
-S,--gpg-sign) - Interactive rebase (
-i,--interactive) - Grafts (
.git/info/grafts) and replace refs (refs/replace/)
Clone
- Recursive clone (
--recursive, submodule auto-init)
Network
- SSH URLs (
git@...) inbit cat/bit treecommands - JS target: SSH transport (
ssh://,git@...) inclone/fetch/pull/push(use HTTP(S) or relay URLs)
Shell
- Shell aliases (prefixed with
!)
BIT_BENCH_GIT_DIR: override .git path for bench_real (x/fs benchmarks).BIT_PACK_CACHE_LIMIT: max number of pack files to keep in memory (default: 2; 0 disables cache).BIT_RACY_GIT: when set, rehash even if stat matches to avoid racy-git false negatives.BIT_WORKSPACE_FINGERPRINT_MODE: workspace fingerprint mode (gitdefault,fastoptional).gitmode follows add-all-style Git-compatible directory snapshots for flow cache decisions.
Mount any commit as a filesystem with lazy blob loading:
let fs = Fs::from_commit(fs, ".git", commit_id)
let files = fs.readdir(fs, "src")
let content = fs.read_file(fs, "src/main.mbt")Git-backed key-value store with Gossip protocol sync:
let db = Kv::init(fs, fs, git_dir, node_id)
db.set(fs, fs, "users/alice/profile", value, ts)
db.sync_with_peer(fs, fs, peer_url)Pull Requests and Issues stored as Git objects:
let hub = Hub::init(fs, fs, git_dir)
let pr = hub.create_pr(fs, fs, "Fix bug", "...",
source_branch, target_branch, author, ts)Apache-2.0