anvil

Anvil Command-Line Interface (CLI) Reference

The anvil command line utility provides both high-level porcelain commands for daily source control workflows and low-level plumbing commands for automation, scripting, and inspection.


Exit Codes

The CLI currently uses these status codes:

There is no separate usage-error status 2. diff does not currently implement --exit-code; a successful comparison returns 0 even when it prints changes.


1. Porcelain Commands

anvil init [path] [--bare]

Initializes a new Anvil repository:

anvil status

Displays working tree status, staged changes, unstaged modifications, untracked files, and unresolved conflict stages.

anvil add [-f | --force] [--] <path>...

Stages file modifications into the directory cache (.anvil/index):

anvil rm [-f] [--cached] <path>...

Removes files from the working tree and staging index:

anvil commit -m <message> [--author <identity>]

Records staged changes into a new commit object:

anvil branch [name] [-d <name> | -D <name>] [-a]

Inspects and manages branches:

anvil checkout <branch-or-commit> [-b <new-branch>]

Switches branches or restores working tree files:

anvil diff [revision] [--cached]

Compares changes between trees, the index, and working copy:

The CLI currently generates patches with Myers diff. The engine’s patience implementation is not exposed by a --patience CLI option.

anvil merge <branch>

Reconciles divergent branches:

anvil rebase <upstream>

Linearly replays commits from the current branch on top of <upstream>:

anvil cherry-pick <commit>

Applies the differential patch of <commit> onto the current working tree and creates a new commit.

anvil reset [--soft | --mixed | --hard] <commit>

Resets current HEAD to specified state:

anvil log [--oneline] [--graph] [-n <count>]

Displays commit history:

anvil blame <file>

Displays line-by-line attribution for a source file, showing commit hash, author name, timestamp, and line number.

anvil tag [name] [-d <name>]

Manages repository tags:

anvil gc

Housekeeping command that packs loose objects into packed containers (.pack and .idx) with delta compression and removes redundant loose files.

anvil fsck

Integrity verification engine:

This command does not currently walk reflogs or independently recompute every object’s digest, pack trailer, and index fanout table. A successful result covers the checks above rather than a complete Git-compatible fsck audit.


2. Plumbing Commands

anvil cat-file [-t | -s | -p | -e] <object-id>

Inspects raw object database entries:

anvil hash-object [-w] [-t blob] [--] <file>

Calculates the content-addressable hash of a file:

anvil ls-tree [-r] <tree-ish>

Lists directory tree object contents:

anvil write-tree

Synthesizes a persistent tree object in the ODB from the staging index and emits the resulting root tree ID.

anvil read-tree <tree-ish>

Populates the staging index with the contents of the given tree object.

anvil commit-tree <tree-id> -m <msg> [-p <parent-id>...]

Creates a raw commit object pointing directly to <tree-id> without modifying HEAD or the index.

anvil rev-parse <revision>

Resolves references, object IDs, ancestor expressions such as main~2 and HEAD^, and reflog expressions such as main@{0} into a raw hexadecimal object ID. Git’s typed peeling syntax, such as v1.0.0^{commit}, is not currently supported by the revision parser.

anvil rev-list [--topo-order] [--count] [--max-count=N] [<revision>...]

Lists commit IDs in topological order from the supplied revisions or ranges. When no revision is supplied, the walk starts at HEAD. An unresolved revision or range exits with an error.

Use --count to print the number of commits selected by the same walk and limits.

Use A...B to list commits reachable from either side after excluding their shared history. Use ^B with one or more starting revisions to exclude commits reachable from B.