gitr 0.1.0

Async typed git CLI wrapper for agents and automation.
Documentation

gitr

CI crates.io docs.rs MSRV License

Async typed git CLI wrapper for agents and automation.

Overview

gitr shells out to the git binary and provides:

  • Async-first — every operation is async via tokio::process::Command.
  • Typed porcelain parsingstatus, worktree list, log, branch parsed into structs.
  • Structured errors — distinguish dirty trees, merge conflicts, missing branches, timeouts.
  • Agent-centric API — worktrees, rebase, merge-tree, stash: everything an AI agent needs.
  • Zero C dependencies — pure Rust, fast compile, easy cross-compile.

Quick start

Add to your Cargo.toml:

[dependencies]
gitr = "0.1"

Open a repository

use gitr::Repository;

#[tokio::main]
async fn main() -> Result<(), gitr::Error> {
    let repo = Repository::open(".").await?;
    let branch = repo.current_branch().await?;
    println!("On branch: {branch}");
    Ok(())
}

Worktree workflow

use gitr::Repository;

#[tokio::main]
async fn main() -> Result<(), gitr::Error> {
    let repo = Repository::open(".").await?;

    repo.worktree_add("/tmp/wt-1", "feature-x").await?;
    let wt = repo.open_worktree("/tmp/wt-1").await?;

    wt.checkout("feature-x").await?;
    // agent works here …
    wt.add_all().await?;
    wt.commit("feat: agent work", &[]).await?;

    repo.worktree_remove("/tmp/wt-1", false).await?;
    Ok(())
}

Feature flags

Feature Default Description
tracing Emit tracing spans for command execution.

MSRV

Rust 1.80.

Changelog

See CHANGELOG.md.

License

MIT