gitr
Async typed git CLI wrapper for agents and automation.
Why gitr?
| Approach | Async | Zero C deps | Worktrees | Rebase | Merge-tree |
|---|---|---|---|---|---|
git2 (libgit2) |
❌ needs spawn_blocking |
❌ | ✅ | ✅ | ❌ |
gix (gitoxide) |
⚠️ partial | ✅ | ❌ | ❌ | ❌ |
gitr |
✅ native | ✅ | ✅ | ✅ | ✅ |
gitr shells out to the git binary and provides structured types, typed errors,
and porcelain parsing. It is the only pure-Rust approach with full feature coverage
for AI agent workflows.
Quick start
Add to your Cargo.toml:
[]
= "0.3"
Open a repository
use Repository;
async
Check status and commit
use Repository;
async
Worktree workflow
use Repository;
async
Read-only merge conflict detection
use Repository;
async
API overview
Repository
- Status:
ensure_clean,status,changed_files,conflicted_files,untracked_files - Branch:
current_branch,branch_create,branch_delete,branch_exists,checkout,default_branch - Commit & Push:
commit,push,push_force,fetch,remote_url - Worktree:
worktree_add,worktree_remove,worktree_list,open_worktree - Merge & Rebase:
merge,merge_tree,rebase,rebase_continue,rebase_abort - Stash:
stash,stash_pop - Diff:
diff,diff_files - Stage:
add,add_all
Errors
gitr::Error (GitError) provides typed variants for every failure mode:
NotARepo— path lacks.gitGitNotFound—gitbinary not inPATHCommandFailed— non-zero exit with stdout/stderr capturedTimeout— command exceeded time budget (default 60s)Dirty— working tree has changesBranchExists/BranchNotFoundWorktreeExistsMergeConflicts
Feature flags
| Feature | Default | Description |
|---|---|---|
tracing |
✅ | Emit tracing spans for command execution. |
test-utils |
❌ | Expose ScriptedRunner for downstream hermetic testing. |
Testing
# All tests (unit + integration + doc-tests)
# With coverage
# Feature powerset
MSRV
Rust 1.80.
Contributing
See CONTRIBUTING.md.
Security
See SECURITY.md.
License
MIT