git-autocommit

command module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 4 Imported by: 0

README

git-autocommit

git-autocommit uses an explicitly selected AI provider to turn local changes into reviewable Git commits. Put the binary on PATH, choose a provider with --provider or trusted configuration, and run git autocommit. It invokes your installed Git, honors hooks/signing, never pushes or changes branches, and refuses conflicts or an in-progress merge, rebase, cherry-pick, or revert.

Install

go install github.com/markosnarinian/git-autocommit@latest
# or download a Linux, macOS, or Windows archive from GitHub Releases

Release archives include amd64 and arm64 binaries and checksums. Building from source is also supported with go build -o git-autocommit ..

Usage

git autocommit --provider amp          # split mode (default)
git autocommit --provider openai --one # one final add -A snapshot
git autocommit --provider amp --staged # cached changes only
git autocommit --provider amp --dry-run
git autocommit --provider amp --yes --style conventional
git autocommit --provider anthropic --model claude-sonnet-4-5
git autocommit --provider amp --prompt 'Mention the issue number'

--split, --one, and --staged are mutually exclusive; an explicit --split overrides a configured mode. Other flags are --config, --provider, --model, --style, --prompt, --dry-run, --yes, --version, and --help.

No AI provider is selected by default. Select one for each run, set GIT_AUTOCOMMIT_PROVIDER, or persist provider in trusted user or Git-local configuration. The command never infers a provider from API keys, installed CLIs, --model, or the number of configured profiles. Once a provider is configured, the shorter examples such as git autocommit --one work as expected.

  • Split commits an existing staged snapshot first, then asks for exact base/worktree line ranges and recalculates after every commit. Binary files, renames, symlinks, and mode changes are selected as whole files.
  • One plans in a temporary index, confirms, stages the final snapshot, verifies it still matches the plan, and creates one commit.
  • Staged only writes a message and commits the existing index. It never stages or unstages working-tree changes.
  • Dry run uses temporary indexes and virtual trees to print every proposed commit without changing HEAD, the real index, or the worktree.

Confirmation is each by default; once and never are available, and --yes means never. Required confirmation fails on non-TTY input rather than assuming approval.

Configuration

TOML is merged in this order: defaults, ~/.config/git-autocommit/config.toml, trusted <git-dir>/autocommit.toml, checked-in .git-autocommit.toml, explicit trusted --config, environment, flags. The checked-in file may only supply styles, history settings, and a repository prompt—it cannot select endpoints, executables, providers, or bypass confirmation.

version = 1
mode = "split"
confirmation = "each" # each, once, never
provider = "openai"
# model = "gpt-5-mini" # optional; provider default is used when omitted
style = "auto" # auto, concise, conventional, detailed
# prompt = "Keep generated files in a separate commit"

[behavior]
staged_in_split = "commit-first" # commit-first, error, flatten
empty_changes = "success"        # success, error
untracked = "include"            # include, skip, error
binary = "whole-file"            # whole-file, error
renames = "whole-file"           # whole-file, error
large_diff = "error"
max_commits = 50
invalid_response_retries = 2
max_diff_bytes = 1048576

[history]
enabled = true
limit = 20
ignore_merges = true
ignore_reverts = true

[providers.local]
kind = "openai-compatible"
protocol = "chat-completions" # default for openai-compatible; responses is also supported
endpoint = "http://localhost:11434/v1/chat/completions"
# api_key_env = "LOCAL_API_KEY" # omit for an unauthenticated local endpoint
default_model = "model-name"

[styles.team]
base = "conventional"
instructions = """
Use imperative subjects and include ticket IDs when visible.
"""
[[styles.team.examples]]
changes = "Add retry timeout"
message = "feat(network): add bounded retries"

Environment overrides: GIT_AUTOCOMMIT_MODE, GIT_AUTOCOMMIT_CONFIRMATION, GIT_AUTOCOMMIT_PROVIDER, GIT_AUTOCOMMIT_MODEL, GIT_AUTOCOMMIT_STYLE, GIT_AUTOCOMMIT_PROMPT, and GIT_AUTOCOMMIT_DRY_RUN.

The auto style follows recent non-merge commits and falls back to concise. concise uses a short imperative subject, conventional uses type(scope): subject, and detailed allows an explanatory body. Custom styles can inherit a built-in and add instructions and any number of changes/message few-shot examples.

Providers

The built-in profiles below are available as explicit choices; none is the default.

  • OpenAI: select openai and set OPENAI_API_KEY; uses the Responses API and defaults to gpt-5-mini unless configured otherwise. OpenAI API billing is separate from a ChatGPT subscription.
  • Anthropic: select anthropic and set ANTHROPIC_API_KEY.
  • OpenAI-compatible: define a trusted profile with kind, endpoint, optional protocol, and optional API-key environment variable. There is intentionally no endpoint CLI flag.
  • Amp CLI: select amp; the model flag is an Amp mode (low, medium, high, ultra). It runs privately in an empty directory with tools and MCP disabled. Amp users can link eligible ChatGPT access first with amp config model-providers add-chatgpt-subscription.
  • Codex CLI (experimental): select codex; it runs ephemeral and read-only in an empty directory and reuses authentication managed by the official Codex CLI. This is the direct option for an eligible ChatGPT/Codex subscription; git-autocommit never reads Codex auth files itself.

API keys are read only from the configured environment variable and are never persisted.

Security and privacy

Diffs and recent commit messages are sent to the selected provider. Review provider retention policies and do not use this tool on secrets. Diff content is treated as untrusted; the model receives no tools and may only return a commit message and validated selections—not code or commands. Binary payload content is not intended for model analysis. Git state is fingerprinted before staging. Hooks can still reject or modify a commit according to normal Git behavior.

MIT © 2026 Markos Narinian.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal
ai
app
git

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL