libra commit

Command reference for `libra commit`

Create a new commit from staged changes.

Alias: ci

Synopsis

libra commit [OPTIONS] -m <MESSAGE>
libra commit [OPTIONS] -F <FILE>
libra commit [OPTIONS] -C <COMMIT>
libra commit [OPTIONS] -c <COMMIT>
libra commit [OPTIONS] -t <FILE>
libra commit [OPTIONS] --date <DATE> -m <MESSAGE>
libra commit [OPTIONS] --fixup <COMMIT>
libra commit [OPTIONS] --squash <COMMIT>
libra commit --amend [--no-edit]
libra commit --no-agent-trailer -m <MESSAGE>

Description

Automatic tracked-file staging with commit -a uses explicit text/eol clean comparison. A CRLF/LF representation difference alone does not create a content change or permit an otherwise empty commit. Real edits are staged through the same conversion used by add. text=auto uses the same comparison with binary detection and protection for historical CRLF index content. See add for --renormalize, bounded index evidence reads and remaining configuration limits.

libra commit creates a new commit from staged changes, builds tree and commit objects, validates messages (including optional conventional commit format and GPG signing via vault), and updates HEAD and refs.

The command reads the index to determine which files are staged, constructs a tree object hierarchy matching the staged content, creates a commit object with the provided message and author/committer metadata, and advances the current branch ref. When vault signing is enabled, the commit is automatically GPG-signed. The .libra/hooks commit lifecycle runs unless bypassed with --no-verify.

Agent session association (CX-23 development)

This option is available in source builds containing CX-23; packaged releases may lag behind this page. It applies only to ordinary libra commit, not the bridge commit.create method and its separate agent_bridge_link graph. agent.commit_trailer defaults to false. To opt in to local association of authorized Codex and other captured sessions, run libra config agent.commit_trailer true. If this opt-in setting cannot be read, Libra keeps association disabled and emits a warning; unrelated commits can still proceed when their other config requirements are met. With the setting enabled, a real commit links at most 64 current-repository/worktree sessions with committed checkpoints that are anchored to the current parent, or active and already linked to that parent; it appends Libra-Agent-Session: <session-id> after the commit-msg hook, before optional vault signing. It follows --trailer and Signed-off-by in the final trailer block. Existing equal trailers are not duplicated. A root commit can select sessions anchored to the unborn parent; more than 64 eligible sessions aborts the commit instead of silently dropping entries. If a hook starts a new trailer paragraph after an equal user trailer, Libra moves that session trailer into the final parseable block so it appears once. --no-agent-trailer suppresses automatic message trailers for one commit while retaining explicitly enabled local links. Dry runs neither link nor preview the automatic trailer. Even with --no-agent-trailer, explicit association still checks the repository catalog, session scope, 64-session cap and workspace lease before moving HEAD. It writes a repository-local .libra/agent-commit-links.v1 prepared intent under the SQLite writer lock before moving the ref. The file is owner-only on Unix, bounded to 10 MiB, synced before the ref move (including the first directory entry on Unix; Windows uses a write-through atomic move), and refuses symlinks. An intent left by a failed ref update is not proof that the commit became reachable. Journal write or sync failure aborts before the ref moves. Association is recorded after HEAD advances; the selected session scope and workspace lease are rechecked in the same database transaction, and a failure is reported as a warning. Amend carries forward still-authorized sessions linked to the commit being replaced and adds newly eligible sessions; both --no-edit and a new -m message emit any missing automatic trailer in the replacement message. The replaced commit retains its existing local link rows. The local journal now retains trailer-free association evidence across a post-ref database failure; libra agent doctor --repair explicitly replays currently authorized links from reachable commits in bounded pages; doctor --commit-link-page N selects the page. Evidence completeness remains unknown even when no link is found. If a journal reaches its 10 MiB bound or contains a corrupt complete frame, inspect it before doctor --repair --reset-commit-link-journal. A readable full journal also requires a live lease, successful repair and cleanup, and no unfinished batch (64 links or 128 candidates). If repair frees enough space, reset is skipped. Add --acknowledge-commit-link-loss when the current 100-commit history page has a next page, or when other worktrees or unreachable commits still hold evidence you intend to discard. The reset does not remove commits or checkpoints. Current cloud refs-only metadata uploads repository refs, not this local SQLite association table. A trailer-free link is one made with --no-agent-trailer; cloud sync does not back it up. A post-ref warning means the commit is complete but its local association may be missing. Keep the commit, journal, and source session; run libra agent doctor --repair in the same worktree. Do not amend solely to retry the link. The warning appears on stderr; with --exit-code-on-warning, the completed commit returns exit 9 / LBR-WARN-001 while JSON remains ok: true. The unreadable opt-in configuration warning follows the same exit-code rule. Commit JSON has no linked-session field. With --amend --no-edit, inherited message text is preserved. A trailer for a session erased or moved out of scope can remain visible in the new commit but does not create a new local link. --no-agent-trailer also leaves inherited or user-written text intact. Check session scope before treating a trailer as recovery evidence. The opt-in trailer is visible to anyone who can read the commit and may be used as a recovery clue only after checking repository/session scope.

Before computing staged changes or writing tree/commit objects, commit validates stage-0 index entries for missing or mistyped blob/tree objects. A corrupt index entry fails closed with LBR-REPO-002 and leaves HEAD unchanged.

An unresolved index (stage 1/2/3 without a stage-0 resolution) blocks a real commit with LBR-CONFLICT-001, including --amend, --allow-empty, and --no-verify. This also applies after a conflicted merge --squash, which has no merge lifecycle state. Resolve the named paths and stage them with libra add <path> before committing. Rejection happens before hooks and tree/commit writes and preserves HEAD, index, and worktree. Like Git, -a first stages the current contents or deletion of conflicted regular files and symlinks, then checks the resulting index; it does not inspect file contents for conflict markers. Unresolved gitlinks require an explicit resolution (for example libra update-index --cacheinfo 160000,<commit>,<path>): Libra does not materialize submodules, so -a cannot infer deletion from an absent submodule directory. Dry-run and porcelain previews preserve the live index, HEAD, and worktree, including when -a previews a resolution. A successful non---dry-run commit that updates HEAD also clears a stopped single-commit cherry-pick or revert (or a sequence sitting on its last item). A multi-commit sequence is kept and the stopped item is recorded as concluded. --dry-run and --porcelain leave that state unchanged.

When a merge is in progress, commit finishes it: the new commit has HEAD plus the recorded merge target(s) as parents, the message defaults to the saved merge message (editor mode strips # Conflicts: comments; --no-edit keeps them; -m/-F override), then merge state is cleared and a held autostash is applied. --amend during a merge is refused (exit 128). --dry-run writes nothing, keeps merge state, and prints a preview instead of a fake [branch hash] line. After merge --squash, the following commit is single-parent, prefills SQUASH_MSG, and deletes that file. Partial commit <path> / commit -o <path> is recognised but refused with LBR-UNSUPPORTED-001 (exit 128); stage only the intended paths first.

For a deleted conflict, use commit -a only when all tracked changes belong in the commit. A parent replaced by a file or symlink makes its tracked children deletions; -a never reads through that symlink. Replacing a conflicted file with a directory containing .git or .libra metadata also requires an explicit gitlink resolution, rather than being automatically staged as a deletion.

Author identity comes from --author, then GIT_AUTHOR_NAME/GIT_AUTHOR_EMAIL, then configured user.name/user.email; committer identity comes from GIT_COMMITTER_NAME/GIT_COMMITTER_EMAIL, then config. Git environment variables take priority over config unless user.useConfigOnly=true, in which case environment identity is ignored. LIBRA_COMMITTER_NAME/LIBRA_COMMITTER_EMAIL remain as lower-priority fallbacks for older automation.

Options

-m, --message <MESSAGE>

Use the given message as the commit message. When omitted (and no -F/-C/--no-edit source is given), the editor is opened to compose the message.

libra commit -m "Add new feature"

-e, --edit

Open the editor to edit the final message even when -m/-F/-C is given (the supplied message is the initial buffer). Conflicts with --no-edit.

libra commit -e -m "Draft message"

--allow-empty-message

Allow a commit whose message is empty after cleanup. This also bypasses the unedited-template abort. It does not imply --allow-empty (an empty index still needs that flag). A commit-msg hook can still reject the empty file.

-t, --template <FILE>

Use the contents of FILE as the initial commit message. With the editor open (the default when no other message source is given), FILE seeds the editor buffer; with --no-edit it is used directly. When the -t flag is unset, the commit.template config (a file path, with a leading ~/ expanded to $HOME) is consulted. The template is ignored when a message source (-m/-F/-C/-c/--fixup/--squash) is given — that source wins and the template file is not even read. As in Git, if the editor leaves the template unchanged the commit is aborted ("you did not edit the message"); a template that cleans to an empty message (comment-only under strip/default) reports aborting commit due to empty commit message instead. --no-edit bypasses the unedited-template check.

libra commit -t .libra/commit-template.txt

-v, --verbose

Show the staged diff in the editor template (below a scissors line, stripped on save) or, when no editor is opened, on stderr. The diff never enters the commit message.

Setting the commit.verbose config to true makes -v the default (an explicit -v on the command line still forces it on). The value is a Git bool-or-int, so commit.verbose=2 is accepted and enables verbose — but Libra's -v is on/off only: there is no -vv verbosity level (no unstaged-diff rendering) and no --no-verbose to force it off for a single commit.

libra commit -v
libra config commit.verbose true   # make -v the default

--no-edit

Reuse the existing message (the --amend parent's, or the one from -m/-F) without opening the editor. Conflicts with --edit.

libra commit --amend --no-edit
libra commit --no-edit -m "msg"

-F, --file <FILE>

Read the commit message from the given file. If both -m and -F are supplied, -m takes precedence. With --amend --no-edit, the original commit message is reused instead.

libra commit -F message.txt

-F <file> / -F -

Read the commit message from <file>; -F - reads it from standard input (Git semantics: the whole stream). The message is cleaned according to --cleanup and the commit-msg hook still runs.

-S / --gpg-sign[=<keyid>]

Force signing with the configured signing source (the generated repository vault key or an imported key), even when commit.gpgSign=false or vault.signing=false. Signing fails if that key cannot be unlocked. The optional key id is accepted for Git parity and ignored (one configured signing source per repository). If combined with --no-gpg-sign, the last flag wins.

--short

Print the short status preview (A path, M path, …). Like --porcelain, --short implies --dry-run: it does not create a commit or change HEAD/index.

-u[=<mode>] / --untracked-files[=<mode>]

Control untracked paths in the status preview: no hides them, normal collapses untracked directories (the default), and all lists individual files. A bare -u or --untracked-files means all; invalid modes fail.

Partial commit (-o / --only, --pathspec-from-file, commit <path>)

Not implemented — Libra commits the whole index. These spellings are recognised and refused with LBR-UNSUPPORTED-001, naming the missing feature and suggesting libra add <path> followed by libra commit, instead of failing as unknown options.

--amend

Replace the tip of the current branch by creating a new commit. The new commit has the same parent(s) as the replaced commit. Cannot amend merge commits (commits with multiple parents). When the index tree and message are unchanged, --amend --no-edit still rewrites the commit and refreshes committer metadata; it never reports a successful amend while leaving HEAD unchanged. With agent.commit_trailer=true, amend carries forward still-authorized sessions linked to the replaced commit and adds newly eligible sessions. Both --amend --no-edit and --amend -m get any missing automatic trailers; the replaced commit keeps its own local link rows.

libra commit --amend
libra commit --amend -m "Updated message"

--conventional

Validate the commit message against the Conventional Commits specification (https://www.conventionalcommits.org). The message must match the pattern <type>[optional scope]: <description>. Fails with an error if validation fails.

libra commit -m "feat: add login" --conventional
libra commit -m "fix(auth): handle expired tokens" --conventional

-a, --all

Automatically stage tracked files that have been modified or deleted before committing. Equivalent to running libra add -u before libra commit. Does not add new untracked files. File modes follow core.filemode: with true (the Unix default) a mode-only change to a tracked regular file is committed too, while false ignores it (an invalid value fails the commit closed). Like Git, -a also re-records the index stat of tracked files whose content is unchanged, so a file that was only touched is not reported by diff-files/diff-index after the commit. Unlike Git, which rolls the refresh back when the commit is refused, Libra writes the index before the commit runs (as it does for auto-staged content), so the refreshed stat is kept even when commit -a then stops with nothing to commit.

Removing the LAST tracked file is still a real change to commit: even though the index becomes empty, commit -a (or libra add -A && libra commit) records the deletion rather than reporting nothing to commit, working tree clean (issue #497). A staged deletion is never confused with a genuinely empty repository, where commit still reports nothing to commit (create/copy files and use 'libra add' to track).

libra commit -a -m "Fix typo"

An intent-to-add entry (libra add -N) is a placeholder, not staged content: commit with only such entries refuses with no changes added to commit, and a commit that stages other paths never records the placeholder (the entry stays in the index). commit -a stages the file's real worktree content, clears the flag, and commits it — matching Git's t2203 behavior.

-s, --signoff

Add a Signed-off-by trailer at the end of the commit message, using the committer's identity.

libra commit -s -m "Add feature"

--allow-empty

Allow creating a commit with no changes (empty diff from parent). Useful for triggering CI or marking milestones.

libra commit --allow-empty -m "Trigger CI"

--disable-pre

Skip only pre-commit. Message hooks and post-operation hooks still run.

libra commit --disable-pre -m "Quick fix"

--no-verify

Skip every .libra/hooks lifecycle hook and commit-message validation for this invocation.

libra commit --no-verify -m "WIP: work in progress"

Repository hooks

The order is pre-commit → prepare-commit-msg → editor/user trailers → commit-msg → automatic agent trailer (opt-in) → optional vault signing → commit/ref update → local agent link (opt-in) → post-commit → post-rewrite for amend. The two message hooks may edit .libra/COMMIT_EDITMSG; blocking hook failures leave history unchanged, while the post hooks are advisory after success. All hooks use the required workspace-only, network-denied sandbox. See Repository hooks for arguments, resolution, output behavior, and escape valves. The commit-msg hook does not see the automatic agent trailer; conventional validation checks the subject after insertion.

--author <AUTHOR>

Override the commit author. Must use the standard A U Thor <author@example.com> format.

libra commit --author "Jane Doe <jane@example.com>" -m "Patch"

--date <DATE>

Set the author date for the new commit. The committer date still uses the current time unless GIT_COMMITTER_DATE is set. Accepted formats include Git raw dates (<unix> <+HHMM|-HHMM>), RFC 3339, YYYY-MM-DD HH:MM:SS +HHMM, YYYY-MM-DD, relative dates such as 2 days ago, and Unix timestamps. --date takes precedence over GIT_AUTHOR_DATE.

libra commit --date "1700000000 +0000" -m "Backdated author timestamp"

Identity And Date Environment

GIT_AUTHOR_NAME, GIT_AUTHOR_EMAIL, and GIT_AUTHOR_DATE set the author identity/date. GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL, and GIT_COMMITTER_DATE set the committer identity/date. If a Git committer identity field is absent, Libra falls back through the matching author field, EMAIL for the email, then LIBRA_COMMITTER_*; config is used after those environment fallbacks. user.useConfigOnly=true disables all identity environment fallbacks, but explicit --author still applies.

--cleanup <MODE>

Clean up the commit message before committing. Accepted values: strip (default, removes commentary lines and trims whitespace), whitespace (only trims whitespace), verbatim (no cleanup), scissors (whitespace cleanup plus truncation at the scissors line — the truncation only applies when the message is edited; on a non-editor -m/-F commit it behaves like whitespace, with no truncation), default (strip when the message is edited, otherwise whitespace).

When --cleanup is not given, the commit.cleanup config value is used as the default (config cascade: local repo, then global); the CLI flag always takes precedence.

libra commit --cleanup=strip -m "feat: add login"
libra config commit.cleanup whitespace   # default cleanup when --cleanup is omitted

--dry-run

Do not actually create the commit. A successful preview shows the commit summary that would be produced. When refusing because there is nothing to commit, the human preview first shows a branch-aware status snapshot (On branch ... plus upstream state). --no-status suppresses this refusal snapshot; commit.status=false also suppresses this refusal snapshot unless --status overrides it. The preview does not run repository hooks or open the commit-message editor, so no message is required and subprocesses cannot observe or mutate a live index while -a is being previewed. -v still prints the staged preview diff directly.

libra commit --dry-run -m "Draft commit"

--porcelain

Print the working-tree status in machine-readable porcelain v1 format (the same as libra status --porcelain: staged changes in column 1, unstaged in column 2, untracked as ??, untracked directories collapsed) instead of the human commit summary, mirroring git commit --porcelain. Like Git, --porcelain implies --dry-run: it prints the would-be-committed state and does not create the commit (and leaves the index untouched, even with -a, which is auto-staged only for the preview). Inert under --json (the JSON envelope is emitted instead).

libra commit --porcelain

--status / --no-status

The commit-message editor template includes the working-tree status as #-commented lines by default. commit.status=false disables it; --status and --no-status explicitly override that config (last flag wins). Because the lines are comments, the message cleanup strips them — they are informational only and never enter the final commit message. For a real commit, this has no effect when no editor is opened (e.g. with -m). Explicit --dry-run also uses the setting and these toggles to collect its preview status, independently of editor cleanup. The editor-template status is also omitted under cleanup modes that keep comment lines (--cleanup=verbatim, --cleanup=whitespace, and --cleanup=scissors — explicit scissors keeps # lines above the marker), so it can never leak into the message; it is seeded only when an editor opens and the effective cleanup strips comments (strip/default). -v only truncates the appended diff — it does not force a strip — so the status stays omitted under those modes even with -v.

commit.status uses the strict local -> global -> system cascade and accepts a Git boolean (including numeric forms such as 0k and 2). When an editor status template can be generated or --dry-run is explicit, an invalid value fails with LBR-CLI-002, and an unreadable local/global config store fails with LBR-IO-001, before -a, hooks, object writes, or history updates — except a future-schema global store (newer than this binary), which is skipped with a one-time warning (see LBR-CONFIG-001). Without explicit --dry-run, -m, porcelain previews, JSON, and non-comment-stripping cleanup bypass the key when no template can exist. An explicit --status or --no-status bypasses the matching config read. When the status section is enabled, failures from its status.* config, collection, or rendering also preserve their stable error code and abort before the pre-commit hook, editor, commit/tree object write, or ref update; --no-status bypasses that template or preview-status path. Consequently, --status with an unreadable shared config store reports the first required status.* key rather than commit.status, proving the explicit toggle skipped the latter read. For --dry-run -a, the entire preview uses a task-local isolated temporary index; the live index is never replaced, and temporary auto-stage blobs, LFS backups, and tree objects are not persisted. Non-verbose previews hash regular files in a 64 KiB stream and retain no payload. Auto-stage detects tracked symlinks without following them (including dangling links and paths matched by an LFS attribute), hashes/stores the link-target bytes, and preserves mode 120000 in real commits and previews. Verbose previews reserve every unique blob on the changed HEAD, already-staged, and newly auto-staged sides before it is loaded, with limits of 32 MiB per blob, 64 MiB aggregate charged scratch, and 4,096 objects. The complete changed-object count is rejected before any storage size batch, loose decode, or pack-index scan. Auto-stage reserves a provisional byte/count slot before reading the worktree payload, then reconciles it by object ID, so neither staging nor hash deduplication can bypass those limits. Scratch lives under the common repository storage at .libra/tmp/commit-preview (shared by linked worktrees), is capped at 256 MiB across concurrent runs, and scavenges at most 32 inactive runs older than 24 hours per bounded startup scan. A run with missing or unreadable reservation metadata fails closed instead of being charged as zero bytes, including while its run lock is still active. Limit failures preserve the live index/object store and advise rerunning without verbose output. A changed blob is likewise refused before loading when its backend cannot perform a bounded local preflight (for example, a remote-only blob or a packed blob whose index is missing); the preview never rebuilds pack indexes. Actual preview reads use an explicit local-only bounded-load API rather than relying on task-local state inside the storage runtime; this path reads existing pack indexes only and never rebuilds unrelated missing indexes. Loose and non-delta packed objects reject an over-limit declared length before decoding the payload; loose objects otherwise stream to the declared boundary and reject size mismatches or bytes after the zlib stream. An oversized delta instruction declaration is rejected before its base chain is visited; accepted packed deltas validate and charge the complete base/instruction/result chain with bounded depth and fail closed on malformed instructions; a batch enumerates packs once and opens each existing index once. The batch receives the remaining aggregate budget, uses the same 4 KiB minimum per-object charge as the cache, and stops probing later pack payloads immediately after the budget is crossed. The subsequent bounded pack read uses an uncached delta decoder and moves its final payload, avoiding the process-wide 200 MiB pack cache and extra full-payload clones. Rerun without verbose output to avoid an unbounded preview load. Dry-run and porcelain previews also skip hooks, editors, rerere updates, and post_commit automation because no commit occurred. When status.showStash=true, an unreadable/non-file stash ref (including a symlink) or an unreadable/corrupt stash log aborts status template collection with LBR-IO-001 before hooks, the editor, or ref writes. The same fail-closed behavior applies to fresh status --cached output. Auto-stage file/LFS reads fail as LBR-IO-001; preview, LFS-backup, and object writes fail as LBR-IO-002 instead of panicking. For a real -a, blob/LFS materialization uses a streamed temporary snapshot, derives the pointer from those exact bytes, and atomically replaces any stale or truncated backup. With --sync-data, newly created shard ancestors, the temporary payload, and both the staging and destination directories are synced around that atomic replacement; Windows uses a write-through atomic replace because it has no portable directory-fsync equivalent. The objects and staged index intentionally remain if later status collection aborts, matching the existing auto-stage-on-abort behavior.

libra commit                   # editor template includes commented status
libra config commit.status false
libra commit --status          # override commit.status=false for this commit
libra commit --no-status       # omit status for this commit

--no-gpg-sign

Force an unsigned commit: skip Libra's vault GPG signing for this commit, matching git commit --no-gpg-sign. Vault signing runs when vault.signing=true (the libra init default) and a vault unseal key is available. The Git-compatible commit.gpgSign=true|false default overrides vault.signing: true force-signs with the configured signing source and false disables signing. --no-gpg-sign has precedence over configuration. When combined with -S/--gpg-sign, the last CLI signing flag wins.

When vault.gpg.source=imported (set by libra config import-gpg-key), commit signing uses the imported signing key instead of the generated vault key; removal (libra config remove-gpg-key --force) falls back to the generated key.

libra commit --no-gpg-sign -m "message"

--fixup <COMMIT>

Create a fixup commit whose message is fixup! <target subject>.

libra commit --fixup HEAD~1

--squash <COMMIT>

Create a squash commit whose message is squash! <target subject>.

libra commit --squash abc1234

-C <COMMIT>, --reuse-message <COMMIT>

Reuse the commit message and author metadata (name, email, author date, and timezone) from the specified commit. The new commit still receives the current committer identity/date, or GIT_COMMITTER_* overrides when set.

libra commit -C HEAD~1

-c <COMMIT>, --reedit-message <COMMIT>

Reuse the commit message and author metadata from the specified commit, then open the editor to edit the message. If no editor is configured, the command uses the reused message unchanged.

libra commit -c HEAD~1

--trailer <TRAILER>

Add a trailer line to the commit message. Can be specified multiple times.

libra commit -m "Add feature" --trailer "Reviewed-by: Jane Doe"

--no-agent-trailer

When agent.commit_trailer=true, skip only automatic Libra-Agent-Session message trailers for this invocation. Local association and its fail-closed catalog, scope, cap and lease checks still run. This flag does not delete user-provided or inherited message text. When the setting is false, the flag has no effect.

libra commit --no-agent-trailer -m "Keep association local"

--reset-author

When amending, reset the author to the current author identity and date instead of preserving the amended commit's original author. Current author identity/date honors GIT_AUTHOR_* and --date as described above. For new non-amend commits this is already the default.

libra commit --amend --reset-author --no-edit

Common Commands

libra commit -m "Add new feature"
libra commit -m "feat: add login" --conventional
libra commit --amend
libra commit --amend --no-edit
libra commit -a -m "Fix typo"
libra commit -F message.txt
libra commit --date "2026-07-09 10:00:00 +0800" -m "Backdated author date"
libra commit -s -m "Add feature"
libra commit --allow-empty -m "Trigger CI"
libra commit --dry-run -m "Draft commit"
libra commit --fixup HEAD~1
libra commit -C HEAD~1
libra commit -m "Add feature" --trailer "Reviewed-by: Jane Doe"
libra commit --json -m "Add feature"

Human Output

Default human mode writes the commit summary to stdout.

Normal commit:

[main abc1234] Add new feature
 2 files changed (new: 1, modified: 1, deleted: 0)

Root commit:

[main (root-commit) abc1234] Initial commit
 1 file changed (new: 1, modified: 0, deleted: 0)

--quiet suppresses all stdout output.

Structured Output

libra commit supports the global --json and --machine flags.

  • --json writes one success envelope to stdout
  • --machine writes the same schema as compact single-line JSON
  • both suppress hook stdout/stderr (piped instead of inherited)
  • stderr stays clean on success unless a completed local commit leaves a durable cloud object-index repair warning or a local agent association/configuration warning (described below)

Example:

{
  "ok": true,
  "command": "commit",
  "data": {
    "head": "main",
    "branch": "main",
    "commit": "abc1234def5678901234567890abcdef12345678",
    "short_id": "abc1234",
    "subject": "Add new feature",
    "root_commit": false,
    "amend": false,
    "files_changed": {
      "total": 2,
      "new": 1,
      "modified": 1,
      "deleted": 0
    },
    "signoff": false,
    "conventional": null,
    "signed": true
  }
}

Root commit:

{
  "ok": true,
  "command": "commit",
  "data": {
    "head": "main",
    "branch": "main",
    "commit": "abc1234def5678901234567890abcdef12345678",
    "short_id": "abc1234",
    "subject": "Initial commit",
    "root_commit": true,
    "amend": false,
    "files_changed": {
      "total": 1,
      "new": 1,
      "modified": 0,
      "deleted": 0
    },
    "signoff": false,
    "conventional": null,
    "signed": true
  }
}

Amend:

{
  "ok": true,
  "command": "commit",
  "data": {
    "head": "main",
    "branch": "main",
    "commit": "def5678abc1234901234567890abcdef12345678",
    "short_id": "def5678",
    "subject": "Amended message",
    "root_commit": false,
    "amend": true,
    "files_changed": {
      "total": 1,
      "new": 0,
      "modified": 1,
      "deleted": 0
    },
    "signoff": false,
    "conventional": null,
    "signed": true
  }
}

Schema Notes

  • head is the branch name or "detached" for backward compatibility
  • branch is null when HEAD is detached; Some(name) otherwise
  • conventional is true when --conventional was passed and validation succeeded; null when not requested
  • signed is true when vault signing is enabled and the commit was GPG-signed
  • signoff is true when -s / --signoff appended a Signed-off-by trailer

Design Rationale

--conventional flag for conventional commits

Git has no built-in support for commit message format validation; teams rely on external tools like commitlint, husky, or CI checks to enforce Conventional Commits. Libra provides first-class --conventional validation directly in the commit command. This serves two purposes: (1) it gives immediate feedback at commit time rather than delayed feedback in CI, and (2) it enables AI agents (which generate commit messages programmatically) to validate their output without external tooling. The flag is opt-in rather than mandatory, respecting teams that use different commit message conventions.

Vault signing by default instead of manual GPG setup

In Git, commit signing requires configuring user.signingkey, gpg.program, and commit.gpgSign -- a multi-step process that most developers skip. Libra's vault automatically generates and manages a PGP signing key at repository initialization, so commits are signed by default with zero configuration. This makes signed commits the norm rather than the exception, improving supply-chain security for the entire ecosystem. Users can use commit.gpgSign for a Git-compatible scoped default; when it is unset, vault.signing remains the Libra default.

--disable-pre flag

The --disable-pre flag skips only the pre-commit hook while still running the message and post-operation hooks. This is more granular than --no-verify, which skips all repository hooks. The use case is when a developer trusts the commit message validation (e.g., conventional commit checks via commit-msg hook) but wants to skip expensive pre-commit checks (e.g., full test suite, large linter runs) during rapid iteration. This separation of concerns is intentional: the commit message is part of the permanent record and should be validated even during quick iterations.

--no-verify to skip hooks

For cases where all hook validation needs to be bypassed (e.g., emergency fixes, WIP commits), --no-verify skips every .libra/hooks lifecycle hook plus commit-message validation. The flag name follows Git's convention, while Libra's additional post-hook bypass is documented explicitly because post hooks are otherwise advisory.

Parameter Comparison: Libra vs Git vs jj

Parameter / Flag Git jj Libra
Commit with message git commit -m "msg" jj commit -m "msg" libra commit -m "msg"
Commit from file git commit -F file N/A libra commit -F file
Amend last commit git commit --amend jj describe (edits working copy commit) libra commit --amend
Amend without edit git commit --amend --no-edit jj describe --no-edit libra commit --amend --no-edit
Auto-stage tracked git commit -a N/A (automatic tracking) libra commit -a
Allow empty commit git commit --allow-empty jj commit --allow-empty libra commit --allow-empty
Signoff trailer git commit -s / --signoff N/A libra commit -s / --signoff
GPG sign commit git commit -S (manual GPG) N/A (no signing) Automatic with the configured source; -S forces signing
Override author git commit --author="..." N/A libra commit --author="..."
Author date git commit --date=<date> N/A libra commit --date <date>
Conventional check External tool (commitlint) N/A libra commit --conventional
Skip pre-commit only N/A N/A libra commit --disable-pre
Skip all hooks git commit --no-verify N/A libra commit --no-verify
Fixup commit git commit --fixup=<commit> N/A libra commit --fixup=<commit>
Squash commit git commit --squash=<commit> jj squash libra commit --squash=<commit>
Reuse message + author git commit -C/-c <commit> N/A libra commit -C/-c <commit>
Interactive message git commit (opens editor) jj commit (opens editor) libra commit / libra commit -e (opens editor)
Verbose diff in editor git commit -v N/A libra commit -v
Status in editor template default on; commit.status / --[no-]status N/A default on; commit.status / --[no-]status
Reset author date git commit --reset-author N/A libra commit --reset-author
Cleanup mode git commit --cleanup=<mode> N/A libra commit --cleanup=<mode>
Trailer git commit --trailer="..." N/A libra commit --trailer="..."
Omit automatic agent trailer N/A N/A libra commit --no-agent-trailer (CX-23 development)
Structured JSON output N/A N/A --json / --machine
Error hints Minimal Minimal Every error type has an actionable hint

Error Handling

Every CommitError variant maps to an explicit StableErrorCode.

A terminal background object_index error does not roll back an already advanced commit and does not turn its JSON success envelope into a contradictory fatal result. Libra retains the exact missing rows in atomic repair markers, warns on stderr, and retries them before the next schema-aware repository command. cloud sync fails closed if repair is still impossible. With --exit-code-on-warning, the completed commit returns exit 9 / LBR-WARN-001; rerunning commit is neither required nor useful. The foreground queue drain is asynchronous and bounded to 60 seconds. On budget expiry the already-created markers remain retryable and the completed commit is reported with a warning; marker-retirement failures also trigger that warning and --exit-code-on-warning behavior. Each queued update retains the invocation that created it, so a late failure cannot make a later embedded command warn or return exit 9. Task-local pending accounting likewise prevents a concurrent direct storage caller from extending this command's drain wait. Repair work uses a separate bounded FIFO lane from direct-library indexing, so a pre-existing direct backlog cannot consume the command's 60-second budget. Repair processes bounded pages; an oversized queue advances over successive commands instead of becoming permanently stuck. Replay and queued writers share a process-crash-safe ownership lock from a bounded 65,536-shard OID namespace through row update and marker retirement, so a delayed writer cannot recreate a row after destructive agent cleanup has consumed that marker. Marker publication also takes a repository-wide generation fence; destructive cleanup revalidates its exact candidate OIDs while holding that fence through the prune transaction. With --sync-data, retiring a marker fsyncs its parent directory.

Scenario Error Code Exit Hint
Unresolved index conflicts LBR-CONFLICT-001 128 Resolve and stage files with libra add; stage deleted conflicts with commit -a only when all tracked changes are intended
Index corrupted LBR-REPO-002 128 "the index file may be corrupted; try 'libra status' to verify"
Index object missing or wrong type LBR-REPO-002 128 "run 'libra fsck' to inspect missing or mistyped objects"
Failed to save index LBR-IO-002 128 --
Nothing to commit (clean) LBR-REPO-003 128 "use 'libra add' to stage changes"
Nothing added (untracked only) LBR-REPO-003 128 "use 'libra add' to track files"
No changes added (unstaged tracked) LBR-REPO-003 128 "use 'libra add' and/or 'libra commit -a'"
Nothing to commit (no tracked) LBR-REPO-003 128 "create/copy files and use 'libra add' to track"
Author identity missing LBR-AUTH-001 128 "run 'libra config user.name ...' and 'libra config user.email ...'"
No commit to amend LBR-REPO-003 128 "create a commit before using --amend"
Amend merge commit LBR-REPO-003 128 "create a new commit instead of amending a merge commit"
Invalid author format LBR-CLI-002 129 "expected format: 'Name '"
Invalid author/committer date LBR-CLI-002 129 Supported date formats
Invalid commit.status LBR-CLI-002 129 Fix the offending config value
Invalid agent.commit_trailer value LBR-CLI-002 129 Set libra config agent.commit_trailer true or false
Agent association catalog/scope/cap/lease refused before ref update LBR-REPO-003 128 Run libra agent doctor; close or inspect old sessions if more than 64 qualify, or renew the workspace lease
commit.status config unreadable LBR-IO-001 128 Repair the local/global config store
Message file unreadable LBR-IO-001 128 --
Empty commit message LBR-REPO-003 128 "use -m to provide a commit message"
Tree creation failed LBR-INTERNAL-001 128 Issues URL
Object storage failed LBR-IO-002 128 When the cause is cloud object-index marker registration, the canonical message applies: payloads were stored safely, no paths were staged, and a direct retry reuses them without lock-file cleanup; lock timeouts name the holder and lock files must never be deleted
Parent commit missing LBR-REPO-002 128 "the parent commit is missing or corrupted"
HEAD update failed LBR-IO-002 128 --
Blocking repository hook failed LBR-REPO-003 128 "use --no-verify to bypass repository hooks"
Conventional commit invalid LBR-CLI-002 129 "see https://www.conventionalcommits.org for format rules"
Vault signing failed LBR-AUTH-001 128 "check vault configuration with 'libra config --list'"
Auto-stage source read/hash failed LBR-IO-001 128 Check the named working-tree file
Auto-stage preview/object/LFS write failed LBR-IO-002 128 Check space and permissions for the named target
Staged changes computation LBR-REPO-002 128 "failed to compute staged changes"
Commit completed but cloud index repair remains pending, with --exit-code-on-warning LBR-WARN-001 9 Fix the reported database/marker error; any next repo command retries the exact rows
Commit completed but local agent link failed, with --exit-code-on-warning LBR-WARN-001 9 Preserve the commit, journal and session; run libra agent doctor --repair in the same worktree; do not amend only to retry

Compatibility Notes

  • libra commit opens the editor to compose the message when no -m/-F/-C source is given (and --no-edit is absent), and -e/--edit always opens it. The editor is resolved as $GIT_EDITOR → core.editor → $VISUAL → $EDITOR → vi. An explicitly configured editor runs even without a TTY; the vi fallback requires an interactive terminal. Without a TTY and without a configured editor, a commit needing a message aborts (it never hangs).
  • -v/--verbose appends the staged diff to the editor template (below a # ----- >8 ----- scissors line); the diff is stripped on save and never enters the commit message. When no editor is opened, -v prints the staged diff to stderr.
  • jj does not have a traditional commit command with staging; jj commit finalizes the working copy commit
  • --fixup and --squash are supported (autosquash markers); --cleanup=<mode> controls comment/scissors stripping
  • Vault signing replaces the external keyring; commit.gpgSign is honored while user.signingkey remains vault-managed
  • Change identity is stored in the sidecar projection (change_identity/change_revision); Libra does not write a change-id commit header. Existing headers are import-compatible metadata only.
  • Remaining unsupported interactive options fail with LBR-UNSUPPORTED-001 (-p/--patch/--interactive, D15). Stage paths with libra add <pathspec> then commit.

Issue #477 notes

concludes an in-progress merge with a two-parent commit no changes added to commit (use "libra add" and/or "libra commit -a") remaining unsupported interactive options fail with LBR-UNSUPPORTED-001 records a commit whose message is empty

clone --separate-git-dir pointer layout: when <worktree>/.libra is a gitdir: pointer file, this command is refused with LBR-UNSUPPORTED-001 before any index, HEAD or ref write. Only status, log, cat-file, the no-argument branch listing, alternates list, clone, upgrade, ui, login, whoami, logout and completions run in that layout.