libra clone

Command reference for `libra clone`

Clone a repository into a new directory.

A Mega2 code view is recognized for https, http, or ssh URLs containing /project/ and .git, unless the URL is a /.traces/ locator. Mega2 code-view clones filter out refs/libra/traces; a Mega2 mirror also uses the heads-only refspec +refs/heads/*:refs/heads/*. A generic mirror clone uses +refs/*:refs/* and may fetch an advertised refs/libra/traces ref. A /.traces/ locator is refused before discovery; use libra mega2 traces fetch for that stream.

Synopsis

libra clone [OPTIONS] <REMOTE_REPO> [LOCAL_PATH]

Description

libra clone creates a local copy of a remote repository by fetching selected objects and refs, configuring a remote named origin by default, and checking out the working tree. Use -o/--origin to choose another remote name. It initializes a vault-backed repository and transparently reuses run_init() for the local metadata setup.

By default, cloning fetches all advertised branch and merge-request refs, plus all tags unless --no-tags is set. Selecting a branch with -b chooses what to check out but does not narrow the fetched refs. Fetch becomes single-branch only with --single-branch or the implicit single-branch mode enabled by --depth, --shallow-since, or --shallow-exclude; --no-single-branch cancels single-branch mode (the last conflicting flag wins). --mirror uses the refspec described above. When the source's HEAD is detached and no --branch is given, --single-branch reproduces that detached HEAD instead of inventing a branch: no local branch and no refs/remotes/<name>/<branch> is created, and the recorded refspec places later fetches under refs/remotes/<name>/_detached/*. A plain clone records remote.<name>.fetch=+refs/heads/*:refs/remotes/<name>/*; a single-branch clone records the narrower +refs/heads/<branch>:refs/remotes/<name>/<branch>, and a --revision clone records none (it creates no remote-tracking refs). Appending another refspec with config set --add remote.<name>.fetch keeps the recorded entry first. Clone creates a .libra directory with a SQLite-backed metadata store, sets up the selected remote, and checks out the default branch (or the branch specified with -b). Vault signing is always bootstrapped during clone, matching libra init defaults. For non-bare clones, any checked-out .gitignore files are copied to matching .libraignore files so Libra ignore rules work immediately. For a checked-out worktree, index stat data is recorded only after each materialized path still matches its source blob and its metadata remains stable across verification; changed or racy files are left for libra status to content-check. Ordinary files are re-hashed after atomic publication before their stat can be trusted. On non-Unix platforms, volatile stat fields remain zeroed because creation time cannot prove that content stayed unchanged; the observed worktree size is retained and status compares content.

For bare clones, no working tree checkout is performed and the repository directory itself becomes the object store. Bare clones do not create .libraignore.

A local Git v2 bundle is a valid source: after a repository directory is ruled out, clone tries <path>.bundle and then <path>. The default destination name drops a .bundle suffix. HEAD is taken from the bundle's HEAD line; if that line is missing, the default branch is checked out when the bundle contains it; otherwise no local branch is created. --depth on a plain-path bundle is ignored with Git's local-clone warning. remote.origin.url records the bundle's absolute path.

Global Config Schema Guard

Configuration schema compatibility is role-scoped. Before libra clone trusts configuration, it inspects GlobalConfig and SystemConfig metadata read-only. A future configuration schema or an unregistered/mismatched migration receipt fails closed with LBR-CONFIG-001 when that scope is required. Known Repository-only receipts, including 2026090801 in the current manifest, do not make a configuration store future; its supported values remain readable. The configuration-owned legacy-reader barrier is recognized by this build; see configuration compatibility.

Global configuration uses LIBRA_CONFIG_GLOBAL_DB or the XDG configuration directory ($XDG_CONFIG_HOME/libra/config.db, defaulting to <home>/.config/libra/config.db), falling back to the legacy <home>/.libra/config.db until it is migrated; system configuration uses LIBRA_CONFIG_SYSTEM_DB or /etc/libra/config.db. Complete process/repo-local storage settings can make GlobalConfig unnecessary (cloud must also satisfy its D1 settings). They do not prove that SystemConfig defaults are unnecessary. Diagnostics identify the affected scope, ledger and version without printing configuration values or untrusted receipt names.

Unknown or unsupported state is upgrade-only here, not automatically repaired. Install a compatible newer Libra binary: curl --proto '=https' --tlsv1.2 -sSf https://download.libra.tools/install.sh | sh. Do not delete or edit SQLite receipts manually. Use --offline or LIBRA_READ_POLICY=offline|local only for intentional local-only object access; these modes warn and are not authorization for remote synchronization.

Checked-out entries carry the tree mode's permission bits (100755 executable, 100644 plain) under the process umask (plan issues/470 FM-01).

Options

<path>.git fallback

When the requested local path is not itself a repository, a plain path and a file:// URL both fall back to <path>.git (Git's clone foo finding the bare foo.git). file:// keeps transport semantics and never hard-links objects.

<REMOTE_REPO> (required)

The remote repository URL to clone from. Supports Git (git://host/user/repo.git), SSH (git@host:user/repo.git), and HTTP(S) (https://host/user/repo.git) protocols, as well as local filesystem paths. The former Cloudflare Publish restore source (libra+cloud://…) was removed with the Publish product. Such a URL is rejected as a usage error (exit 129), with a hint to clone a Git remote or use libra cloud for repository backup. The cloud.clone_domains.* config keys are frozen and are no longer read.

libra clone git@github.com:user/repo.git
libra clone https://github.com/user/repo.git
libra clone git://host/user/repo.git
libra clone /path/to/local/repo

[LOCAL_PATH]

Optional destination directory. When omitted, Libra infers the directory name from the repository URL (e.g., repo from repo.git or repo.bundle). --bare and --mirror use <basename>.git. Empty names and .. are rejected. If inference fails, an error is returned asking the user to specify the path explicitly.

libra clone git@github.com:user/repo.git my-dir

-b, --branch <NAME>

Check out <NAME> instead of the remote's HEAD. The branch must exist on the remote; otherwise a "remote branch not found" error is raised.

libra clone -b develop git@github.com:user/repo.git

--single-branch

Fetch only the history leading to the tip of a single branch (HEAD, or the branch given by -b). Reduces transfer size for large repositories when only one branch is needed. This mode is enabled explicitly by --single-branch, or implicitly by --depth, --shallow-since, and --shallow-exclude unless --no-single-branch is given (matching git clone). A mirror does not enable single-branch mode; its ref coverage follows the mirror refspec below. A single-branch clone writes remote.<name>.fetch=+refs/heads/<branch>:refs/remotes/<name>/<branch>. Only Git remotes support this transport optimization.

libra clone --single-branch -b main git@github.com:user/repo.git

--no-single-branch

Clone the histories of all branches (the default), countermanding an earlier --single-branch (last one on the command line wins). Clone fetches all branches by default, so on its own this is a no-op.

libra clone --single-branch --no-single-branch git@github.com:user/repo.git

--bare

Create a bare repository without a working tree. The destination directory becomes the object store directly. When the destination is omitted, the default name is <basename>.git. Libra stores libra.db and objects at the destination root (no Git-style config/HEAD/refs files). A bare clone writes no index and no working-tree files. Useful for central/server-side repositories.

libra clone --bare git@github.com:user/repo.git

--mirror

Set up a mirror of the source repository (like git clone --mirror). Implies --bare and keeps no refs/remotes/* tracking refs. For ordinary remotes it maps advertised refs verbatim and records remote.<name>.fetch=+refs/*:refs/*. For a Mega2 code-view remote it records remote.<name>.fetch=+refs/heads/*:refs/heads/* and excludes refs/libra/traces. Both modes record remote.<name>.mirror=true. Useful for serving or backing up a repository.

libra clone --mirror git@github.com:user/repo.git repo-mirror.git

--filter <spec> / --shallow-since <date> / --shallow-exclude <rev>

Git's fetch-shaping flags that reduce what is transferred. --filter=blob:none is a partial clone: a local transport (file:// or --no-local) transfers commits and trees only and records the promisor configuration (remote.<name>.promisor=true, remote.<name>.partialclonefilter=blob:none, extensions.partialClone=<name>, using the effective remote name from -o or clone.defaultRemoteName); a missing object is then fetched on demand from that promisor remote. combine:blob:none+tree:1 (and the equivalent --filter=tree:1 --filter=blob:none, in either order) transfers commits and their root trees only, recorded as remote.<name>.partialclonefilter=combine:blob:none+tree:1. Every other filter spec fails closed with LBR-UNSUPPORTED-001 (tree:<depth> other than 1, object:type=<type>, blob:limit=<n>, sparse:path=<path>, any other combine:..., and repeated --filter values that do not normalize to one of the supported forms); --filter=sparse:oid=<rev>:<path> reads the sparse rules from the blob at <rev>:<path> and keeps every commit and tree plus only the blobs whose path matches a rule, recording remote.<name>.partialclonefilter=sparse:oid=<rev>:<path>; a filtered-out blob is then fetched on demand from the promisor remote; that on-demand fetch reports Receiving objects like any other transfer, following the global --progress setting (auto draws it only on a terminal, text always, none never). When the source does not advertise the filter capability the clone falls back to a full clone (no promisor rows are recorded). Network filter negotiation is not implemented yet. --shallow-since and --shallow-exclude bound shallow history by date or excluded ref, but Libra's fetch uses only --depth to request a new shallow cutoff, so those two are accepted but ignored, with a warning. Without --depth, Libra fetches the history available from the source; an already-shallow source still produces a shallow clone with its advertised boundaries preserved. --shallow-exclude may be given multiple times.

libra clone --filter blob:none git@github.com:user/repo.git
libra clone --shallow-since "2 weeks ago" git@github.com:user/repo.git

--sparse

Initialise a cone-mode sparse checkout during the clone: only the top-level files are materialised (the index is narrowed before anything is written, so a --filter=blob:none clone fetches only those blobs), while every deeper path stays in the index with the skip-worktree bit set (libra ls-files -t shows them as S). The clone records core.sparseCheckout=true and core.sparseCheckoutCone=true; cone rule files and rule management are not implemented yet, and the checkout-family commands (checkout, switch, reset, restore, merge, pull, rebase, cherry-pick, stash) fail closed with LBR-UNSUPPORTED-001 in such a repository, except for merge of the directory-rename shape (our side moved a whole directory, their side only added files), which applies the rename and fetches every object it needs in a single promisor batch.

libra clone --sparse --filter=blob:none git@github.com:user/repo.git

--ref-storage-format <format>

Git's --ref-storage-format: Libra stores refs in SQLite, so sqlite is accepted as a no-op and every other format fails closed — files and reftable are unimplemented (LBR-UNSUPPORTED-001), an unknown value is a usage error (LBR-CLI-002, Git's unknown ref storage format). libra rev-parse --show-ref-storage-format reports the backend truthfully.

libra clone --ref-storage-format=sqlite git@github.com:user/repo.git

-l, --local / --no-local

Match Git's local-clone vs transport choice for a plain filesystem Git path. A non-shallow plain path defaults to local-clone semantics (also restored by -l/--local): --depth, --shallow-since, --shallow-exclude, and --filter are ignored and Git's warning text is printed (warning: --depth is ignored in local clones; use file:// instead. and the matching --shallow-* / --filter lines). An already shallow Git source uses transport so its boundaries are preserved. --no-local (or a file:// URL) uses the transport and honors --depth. A local Libra source now hard-links its object store when source and destination share a filesystem (copy fallback after the first hard-link failure; explicit --local fails closed with LBR-IO-002), while --no-local keeps the copied transport path. The two flags override each other; the last one given wins. A local Libra source is unchanged: --depth fails closed with LBR-REPO-002 on both a plain path and file://.

libra clone -l /path/to/source /path/to/dest

A local-path clone of a large repository (thousands of commits / hundreds of thousands of reachable objects) is encoded through the same shared pack encoder as repack/pack-objects/maintenance; it does not hang at “Fetching objects” (ADR-CLH-01 / issues/496).

--depth <N>

Create a shallow clone with history truncated to the specified number of commits. N must be a positive integer. Implies --single-branch unless --no-single-branch is given (matching git clone). Git sources using transport semantics support shallow transfer, including file:// URLs, --no-local paths, and already shallow local Git paths. A local Libra source rejects --depth with LBR-REPO-002: that transport cannot advertise shallow boundaries, so accepting the option would leave a clone with missing parents. This fail-closed behavior is the accepted end state (decision D20 in the development compatibility register), not a pending gap. A non-shallow plain filesystem Git path ignores --depth and warns (issues/474 CL-06). A local Git source reached with file:// or --no-local truncates by the shortest distance from any wanted tip, then one boundary pass: a commit is shallow when a parent was not sent, or when a root commit sits exactly on the depth cutoff (issues/474 CL-04).

libra clone --depth 1 git@github.com:user/repo.git
libra clone --depth 50 git@github.com:user/repo.git

--reject-shallow / --no-reject-shallow

--reject-shallow and --no-reject-shallow are a toggle pair: the last one wins, so --reject-shallow --no-reject-shallow clones a shallow source normally and --no-reject-shallow --reject-shallow rejects it. --no-reject-shallow alone is the default (a no-op).

A shallow local Git source is rejected before creating the destination, even when --depth is also given (exit 128, matching git clone --reject-shallow). Without this flag, cloning a shallow Git source copies its .git/shallow boundaries into .libra/shallow so log / fsck stay walkable. A local Libra source with --depth still fails closed with LBR-REPO-002 before object transfer.

For network remotes, --reject-shallow currently rejects a shallow result after fetch only when --depth was not requested. With --depth, the network post-fetch check is skipped even if the source is shallow; this is narrower than Git's source check.

Git, HTTPS, and SSH sources can advertise existing shallow boundaries. Libra preserves those boundaries during a clone and rejects an advertisement with more than 4,096 distinct boundaries to keep object-store checks bounded. An upload-pack response likewise accepts at most 4,096 distinct OIDs across its shallow and unshallow boundary lines. Those response lines are capped at 8,192 in total, including duplicates; OIDs are checked against the server's object format, with violations returning LBR-NET-002. Inspecting those boundary commits is limited to 4 MiB of decoded payload per commit, 64 MiB of decoded commit payload per clone, and 262,144 parent IDs in total. Exceeding a limit aborts the clone; aggregate-limit errors suggest fetching fewer refs or asking the remote owner to reduce its shallow boundaries. Network Git (git://), HTTP(S), and SSH clone fetches verify wanted objects and fetched commit-parent links against final shallow boundaries before updating refs; an unmarked missing parent causes failure. These checks cap the temporary parent-edge spool at 1 GiB and the pack's temporary commit-ID buffer at 64 MiB (currently up to 2,097,152 commits) per fetch. Either limit can reject an otherwise valid large pack before refs are updated; it does not imply pack corruption. When depth-response shallow markers need further validation, at most 16,384 requested objects or tag targets are inspected. The shallow-marker ancestry walk separately caps visited commits and parent edges at 262,144 each. Remote type probes and inspected tags share a 256 MiB decoded object-payload budget across each shallow response validation. If a limit is exceeded, select fewer refs (for example, --single-branch) and fetch the rest separately. Smart HTTP additionally rechecks the boundaries after the upload-pack POST. If they changed since discovery, clone reports NetworkProtocol with a retry hint before writing the pack or refs and attempts to remove the partial destination.

libra clone --reject-shallow git@github.com:user/repo.git

--reference <repo> / --reference-if-able <repo> / --shared (-s) / --no-shared / --dissociate

Git's object-sharing flags, which set up objects/info/alternates so a clone borrows or shares objects with another local store. Libra copies every fetched object in v1, but can also register a guarded object alternate for a local Libra source:

  • --shared (-s) registers the local Libra source as an alternate for borrowed reads and protects its objects from GC/eviction/obliteration. Registration failures warn but do not fail the clone; all fetched objects were already copied, so registration saves no disk space in v1. An explicit --shared on a local Git or network source has no effect and warns. clone.shared=true enables this by default when the source is eligible.
  • --no-shared disables alternate registration, overriding --shared or the config default. --dissociate also disables registration; v1 has no borrowed clone objects to copy back.
  • --reference <repo> is still a no-op with a warning: Libra has no fetch-side alternate negotiation for this flag. It may be given multiple times.
  • --reference-if-able <repo> is silently ignored — matching Git, which silently drops a reference it cannot use (here, none are usable). May be given multiple times.

Without --depth, clone fetches the history available from the source; an already-shallow source retains its shallow boundaries.

libra clone --reference /path/to/local/mirror git@github.com:user/repo.git
libra clone --dissociate git@github.com:user/repo.git

--tags / --no-tags

libra clone fetches all tags by default (matching Git). --no-tags clones without any tags and records remote.<name>.tagOpt=--no-tags (the remote name is origin by default, or the -o/--origin value), so subsequent libra fetch calls also skip tags. --tags is accepted for compatibility and to override an earlier --no-tags (last flag wins).

libra clone --no-tags git@github.com:user/repo.git

--progress

Emit a completion progress line (Receiving objects: 100%) on stderr when stderr is redirected to a file or pipe (non-TTY). On a TTY the interactive spinner is used instead. --progress is a boolean flag: the repository URL remains the positional source and is not consumed as the flag's value. Use --progress=<MODE> for an explicit global mode, and --progress=none (or --no-progress) to suppress the completion line. The four legacy mode tokens json, text, none, and auto immediately after a bare --progress are still consumed as modes; separate a source with one of those exact names using -- (for example libra clone --progress -- text dest).

libra clone --progress https://github.com/user/repo.git

--no-progress

Suppress the fetch progress meter (the "Receiving objects" spinner) during the clone, matching git clone --no-progress. Other output is unaffected.

libra clone --no-progress git@github.com:user/repo.git

-n, --no-checkout

Do not check out HEAD into the working tree after cloning, matching git clone -n / git clone --no-checkout. Objects, refs and HEAD are still set up — only the working-tree checkout is skipped, so the destination contains the repository metadata but no checked-out files.

libra clone -n git@github.com:user/repo.git

-c, --config <key=value>

Set a configuration value in the new repository, matching git clone -c. The option is repeatable and values are recorded in command-line order, so -c a.b=1 -c a.b=2 stores both. clone.defaultRemoteName=<name> takes effect before the initial fetch (the tracking refs use that remote name); an explicit -o/--origin wins over it, and a global clone.defaultRemoteName applies when neither flag is given. An empty key (-c =v) is refused with LBR-CLI-002.

libra clone -c core.foo=bar git@github.com:user/repo.git

--revision <REV>

Clone only the given revision (for example refs/heads/main or refs/tags/v1) and check it out as a detached HEAD, matching git clone --revision. No local branches, tags or remote-tracking refs are created and remote.<name>.fetch is not written, so the clone carries only the objects reachable from that revision. Conflicts with --branch and --mirror (LBR-CLI-002).

libra clone --revision=refs/tags/v1 git@github.com:user/repo.git

--separate-git-dir <DIR>

Store the repository metadata in <DIR> instead of <workdir>/.libra, and leave a gitdir: <DIR> pointer file at <workdir>/.libra, matching git clone --separate-git-dir. The clone itself — including the initial checkout — runs with the metadata inside the worktree; it is moved to <DIR> only after the checkout completes, so a failed clone never leaves a half-relocated repository. <DIR> must not exist or must be an empty directory. Cannot be combined with --bare or --mirror (options '--bare' and '--separate-git-dir' cannot be used together, LBR-CLI-002). Commands that only read the repository — status, log, cat-file and the no-argument branch listing — resolve the pointer layout and operate on <DIR>; commands that write refs are refused until the follow-up cards land.

libra clone --separate-git-dir ~/.libra-meta/repo git@github.com:user/repo.git

-o, --origin <NAME>

Use <NAME> for the remote (and its refs/remotes/<NAME>/* tracking refs) instead of the default origin, matching git clone -o. The branch tracking config (branch.<branch>.remote) and remote.<NAME>.url use the chosen name. This applies to standard clones.

libra clone -o upstream git@github.com:user/repo.git

--deps-of <path> / --deps-depth-limit <N> (dependency-filtered clone, lore.md 3.2)

Libra-only extension (intentionally-different — Git has no file-dependency concept). After a normal, fully checked-out and commit-safe clone, scope the read-only sparse VIEW (sparse-view, lore.md 2.2) to the forward dependency closure (deps, lore.md 3.1) of the given root path(s). --deps-of is repeatable; --deps-depth-limit <N> bounds the closure depth (1 = direct dependencies only). It implies --notes (the dependency graph must be fetched to compute the closure) and records remote.<name>.fetchNotesDeps=true so later libra pull keeps the graph fresh.

This is not partial clone (--filter) and not --sparse (declined, D10): objects are never wire-filtered — the whole pack is downloaded and the whole tree stays on disk. Only the VIEW is narrowed (ls-files/status/diff scope to the closure); reducing on-disk footprint is deferred (D18, needs the D10 skip-worktree machinery). Only a local Libra source can travel the dependency graph in v1 (D17); a network or plain-Git source clones without dependency scoping (subject to --depth and the source's shallow boundaries) and warns. Conflicts with --no-checkout/--bare/ --mirror (they skip the checkout that keeps the repository commit-safe).

libra clone --deps-of scene.usd /path/to/local-libra-repo my-scene
libra clone --deps-of a.txt --deps-depth-limit 1 /path/to/src direct-only

Common Commands

libra clone git@github.com:user/repo.git
libra clone https://github.com/user/repo.git
libra clone git@github.com:user/repo.git my-dir
libra clone --bare git@github.com:user/repo.git
libra clone --no-checkout git@github.com:user/repo.git
libra clone -b develop git@github.com:user/repo.git
libra clone --single-branch -b main git@github.com:user/repo.git
libra clone --depth 1 git@github.com:user/repo.git

Human Output

Default human mode writes staged progress to stderr and the final summary to stdout.

Phases:

  • Connecting to <url> ...
  • Initializing repository ...
  • Fetching objects ...
  • Configuring repository ...
  • Checking out working copy ... (non-bare only)

Success output:

Cloned into 'repo'
  remote: origin -> git@github.com:user/repo.git
  branch: main
  signing: enabled

Tip: using existing SSH key at ~/.ssh/id_ed25519

Bare clone:

Cloned into bare repository '/path/to/repo.git'
  remote: origin -> git@github.com:user/repo.git
  branch: main
  signing: enabled

Empty remote:

Cloned into 'empty'
  remote: origin -> git@github.com:user/empty.git
  signing: enabled

warning: You appear to have cloned an empty repository.

--quiet suppresses all progress and the final success summary, including warnings.

Structured Output

libra clone 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 progress output and nested init/fetch output
  • stderr stays clean on success

Example:

{
  "ok": true,
  "command": "clone",
  "data": {
    "path": "/Users/eli/projects/my-repo",
    "bare": false,
    "remote_url": "git@github.com:user/repo.git",
    "remote_name": "origin",
    "branch": "main",
    "object_format": "sha1",
    "repo_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "vault_signing": true,
    "ssh_key_detected": "/Users/eli/.ssh/id_ed25519",
    "shallow": false,
    "warnings": [],
    "gitignore_converted": [".libraignore"],
    "objects_fetched": 42,
    "bytes_received": 4096
  }
}

Empty remote returns "branch": null and a warning:

{
  "ok": true,
  "command": "clone",
  "data": {
    "path": "/Users/eli/projects/empty-repo",
    "bare": false,
    "remote_url": "git@github.com:user/empty-repo.git",
    "remote_name": "origin",
    "branch": null,
    "object_format": "sha1",
    "repo_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "vault_signing": true,
    "ssh_key_detected": null,
    "shallow": false,
    "warnings": [
      "You appear to have cloned an empty repository."
    ],
    "gitignore_converted": [],
    "objects_fetched": 0,
    "bytes_received": 0
  }
}

Schema Notes

  • remote_name is the configured remote's name (origin by default, or the -o/--origin value for standard clones)
  • branch is the actual checked-out branch; null when the remote has no refs
  • shallow reports whether an effective --depth fetch was used; false does not rule out inherited shallow boundaries from the source
  • gitignore_converted lists the worktree-relative .libraignore files written from converted .gitignore files; always present (empty for bare clones or when the source has no .gitignore)
  • source_kind and cloud_site are reserved optional fields and are omitted for every currently supported clone source
  • ref_format and converted_from from init are intentionally excluded
  • objects_fetched / bytes_received report the fetch pack's object count and byte size for Git sources

Design Rationale

No --recurse-submodules

Git's submodule system (--recurse-submodules) is a frequent source of developer friction: submodules require separate fetch/checkout cycles, create nested .git directories, and break many tools that assume a single worktree. Libra does not implement submodules. For monorepo workflows, all code lives in a single repository. For multi-repo composition, Libra encourages explicit dependency management (package managers, vendoring) rather than embedding repositories within repositories. This keeps the clone operation simple and predictable.

Vault bootstrapping during clone

Libra initializes vault-backed signing during clone by reusing the same run_init() path as libra init. This means every cloned repository is immediately ready for signed commits without additional setup. Git requires users to manually configure GPG/SSH signing after cloning, which means most cloned repositories produce unsigned commits by default. By bootstrapping the vault at clone time, Libra ensures that the security posture of a cloned repository matches that of a freshly initialized one.

Ignore file conversion

Libra uses .libraignore for its ignore policy. During non-bare clone, every checked-out .gitignore is copied to a sibling .libraignore. Existing user-owned .libraignore files are preserved and surfaced as warnings; the original .gitignore files remain untouched.

--depth for shallow clones

Shallow clones are essential for CI/CD pipelines and large monorepos where full history is unnecessary. Libra supports --depth N for Git remotes that negotiate shallow boundaries: the history is truncated to the specified number of commits. The depth value is validated at parse time (must be a positive integer) and propagated to the fetch protocol layer. Local Libra sources fail closed with LBR-REPO-002 — the accepted end state (decision D20), since they cannot produce shallow boundary metadata. Libra requests a new shallow-history limit only with --depth: the date/ref-based --shallow-since and --shallow-exclude flags are accepted but ignored with a warning (see their Options entry above) rather than rejected, so scripts that pass them still clone successfully. An already-shallow source retains its advertised boundaries without --depth.

--sparse is intentionally unsupported

Sparse-checkout (git clone --sparse, git sparse-checkout) is intentionally not implemented. Sparse cone/skip-worktree relies on Git-managed worktree configuration, while Libra has migrated config / HEAD / refs to SQLite. The bridge is not free, and the audit-driven decision is to keep --sparse deferred until there is a concrete monorepo subtree-checkout requirement that cannot be met by tiered cloud storage. See docs/development/commands/_compatibility.md entry D10 for the restart conditions.

--recurse-submodules is intentionally unsupported

Per the broader product boundary on submodules (no submodule subcommand surface), clone --recurse-submodules is also unsupported. See docs/development/commands/_compatibility.md entries D1 (submodule) and D4 (clone --recurse-submodules) for restart conditions.

--single-branch flag

When combined with --branch, --single-branch reduces the data transferred during clone by fetching only the specified branch's history; --branch alone still fetches all default refs. --depth / --shallow-since / --shallow-exclude imply the same narrowing unless --no-single-branch is given. Mirrors follow their configured mirror refspec instead. This is particularly useful for large repositories with many long-lived branches where only one branch is needed for the current workflow (e.g., CI building a specific release branch). Git supports this as well; jj does not, because its operation-log model fetches all refs by design.

Parameter Comparison: Libra vs Git vs jj

Parameter / Flag Git jj Libra
Remote URL (positional) git clone <url> jj git clone <url> libra clone <url>
Destination directory git clone <url> <dir> jj git clone <url> <dir> libra clone <url> <dir>
Specific branch -b / --branch -b / --branch (jj 0.17+) -b / --branch
Single branch --single-branch N/A --single-branch
No single branch --no-single-branch N/A --no-single-branch (countermands --single-branch; all branches is the default)
Bare clone --bare N/A --bare
Shallow clone (depth) --depth <n> N/A supported for Git remotes; local Libra sources fail closed (LBR-REPO-002)
Shallow since date --shallow-since=<date> N/A accepted no-op for Git remotes (ignored + warning; no new cutoff except --depth; source shallow boundaries preserved)
Shallow exclude --shallow-exclude=<rev> N/A accepted no-op for Git remotes (ignored + warning; no new cutoff except --depth; source shallow boundaries preserved)
Mirror clone --mirror N/A --mirror (implies --bare, no tracking refs; ordinary remotes use +refs/*:refs/*, while Mega2 code-view remotes use +refs/heads/*:refs/heads/* and exclude refs/libra/traces)
Reference repository --reference <repo> / --reference-if-able <repo> N/A accepted no-op (no fetch-side alternate negotiation); --reference warns, --reference-if-able silent
Shared object store --shared / -s N/A guarded alternate for local Libra source; v1 still copies objects; explicit use on other sources warns
Dissociate from reference --dissociate N/A disables shared alternate registration; fetched objects are already copied
No hardlinks --no-hardlinks N/A Force copying local objects instead of hard-linking
Recurse submodules --recurse-submodules N/A N/A (no submodules)
Shallow submodules --shallow-submodules N/A N/A
Separate git dir --separate-git-dir=<dir> N/A N/A (removed)
Template directory --template=<dir> N/A N/A (handled by init internally)
Quiet mode -q / --quiet --quiet --quiet (global flag)
Verbose / progress --progress / --verbose N/A --progress is a boolean clone flag; bare --progress emits a completion line on redirected stderr; --progress=<mode> selects an explicit global mode; --verbose N/A
No checkout -n / --no-checkout N/A --no-checkout
Sparse checkout --sparse N/A N/A
Filter (partial clone) --filter=<spec> N/A accepted no-op for Git remotes (ignored + warning; no new cutoff except --depth; source shallow boundaries preserved)
Bundle URI --bundle-uri=<uri> N/A N/A
Vault signing bootstrap N/A N/A Always enabled (matches init)
SSH key detection N/A N/A Automatic detection + hint
Structured JSON output N/A N/A --json / --machine
Error hints Minimal messages Minimal messages Every error type has an actionable hint

Error Handling

HTTP(S) discovery runs before the destination repository exists. When no local repository is available, it uses the default protocol v2 negotiation and accepts legacy server advertisements through fallback.

Every CloneError variant maps to an explicit StableErrorCode -- no message substring inference.

Scenario Error Code Exit Hint
Cannot infer destination path LBR-CLI-002 129 "please specify the destination path explicitly"
Destination exists and is non-empty LBR-CLI-003 129 "choose a different path or empty the directory first"
Destination already contains a repo LBR-REPO-003 128 "the destination already contains a libra repository"
Cannot create destination directory LBR-IO-002 128 "check directory permissions and disk space"
Local path does not exist LBR-REPO-001 128 "use a valid libra repository path or a reachable remote URL"
Malformed URL or unsupported scheme LBR-CLI-003 129 "check the clone URL or scheme"
Authentication / permission denied LBR-AUTH-002 128 "check SSH key / HTTP credentials and repository access rights"
SSH public-key rejection during discovery LBR-AUTH-002 128 Check the selected key, SSH agent and repository access; see the SSH setup guide
Network unreachable LBR-NET-001 128 "check the remote host, DNS, VPN/proxy, and network connectivity"
pkt-line discovery / transfer framing error LBR-NET-002 128 "check that the remote serves Git data and that a proxy has not altered the response"
Server replies with protocol v2 after legacy discovery was selected LBR-NET-002 128 "use a remote whose server also serves protocol v0/v1 advertisements, or use Git for this remote"
Other discovery protocol error LBR-NET-002 128 "the remote did not complete discovery successfully; retry and inspect server/protocol settings"
Remote branch not found LBR-REPO-003 128 "use -b <branch> to specify an existing branch"
Object format mismatch LBR-REPO-003 128 "the remote and local repository use different object formats"
Checkout resolve failure LBR-REPO-003 128 "working tree checkout target could not be resolved"
Checkout read failure LBR-IO-001 128 "failed to read repository state while checking out"
Checkout write failure LBR-IO-002 128 "files could not be written"
Checkout LFS download failure LBR-NET-001 128 "LFS content transfer failed"
Internal invariant LBR-INTERNAL-001 128 Issues URL

Wire kind is capability-first: discovery reads object-format (default sha1) before validating OID width, so a 64-hex advertisement without the capability fails closed instead of inferring sha256. Libra↔Libra blake3 clones advertise/negotiate object-format=blake3 and initialize the destination from the discovery kind. Format mismatch maps to LBR-REPO-003 (exit 128) with a blake3-extension hint when either side is blake3. Covered by blake3_clone_round_trip, clone_sha256_libra_local_remote_succeeds, and protocol_object_format_mismatch_error_contract.

Local Git sha256 reject (B3-12): a local-path Git source with extensions.objectformat=sha256 is refused before any destination write (LBR-CLI-002, exit 129); create SHA-256/BLAKE3 Libra repositories with a fresh libra init --object-format instead. Unknown/corrupt source objectformat → LBR-REPO-002; unreadable config → LBR-IO-001. Network Git sha256 sources remain deferred (DEFER-B3-10). Covered by clone_rejects_sha256_git_source and clone_rejects_unknown_git_source_format.

Cloud backup restore kind (B3-14): libra cloud restore uses D1 repositories.object_format metadata only (never o_id length). See cloud.md.

Init errors are transparently forwarded through InitError -> CliError.

Cleanup Failure Visibility

When clone fails, cleanup_failed_clone() attempts to remove the partially created directory. If cleanup itself fails, the warning is attached to the error via with_priority_hint() so it surfaces in both human and JSON error output instead of being silently swallowed.

Non-Bare Checkout Is Required For Success

setup_repository() uses execute_checked_typed() which returns typed RestoreError variants. If checkout fails, the clone reports failure -- it does not silently succeed with a broken worktree.

Vault And Identity

  • Clone always initializes with vault: true, matching libra init defaults
  • vault_signing and ssh_key_detected from init are transparently forwarded to CloneOutput
  • SSH key detection uses the isolated HOME from the init phase

Compatibility Notes

  • --recurse-submodules is not supported; Libra does not implement submodules
  • --reference/--reference-if-able remain no-ops; --shared can register a guarded alternate for a local Libra source, while --no-shared/--dissociate disable registration. V1 still copies every fetched object.
  • Clone always bootstraps vault signing; use libra config to disable after cloning if needed
  • The --depth value must be a positive integer; zero or negative values are rejected at parse time
  • --no-checkout sets up objects/refs/HEAD but skips the working-tree checkout; use --bare instead when you want no working tree at all (no .libra worktree layout)

Malformed HTTP(S) discovery responses

During HTTP(S) reference discovery, Libra rejects a zero-byte advertisement and malformed pkt-line frames, including short or non-hexadecimal headers, frame lengths below four, and truncated payloads. A valid 0000 flush remains distinct from an absent response; a valid empty-repository advertisement is supported. An unsupported object-format capability reports the fixed message Unsupported object format capability without echoing its remote value. Check that the URL points to a Git smart HTTP service and that a proxy has not truncated or replaced the response; then retry.

pkt-line error classification

Detected pkt-line framing errors return LBR-NET-002 (exit 128), including an empty HTTP(S) discovery advertisement. Ordinary connection failures, resets and timeouts return LBR-NET-001 (exit 128). Verify the Git service and any proxy response when a protocol error occurs. Discovery framing errors use the hint check that the remote serves Git data and that a proxy has not altered the response.

The same protocol classification and hint apply during object transfer, including a truncated pkt-line header or payload. An ordinary IO failure without a pkt-line marker during discovery remains LBR-IO-001; host-key diagnostic handling is described in the SSH section below.

Pack completeness is separate from pkt-line framing: an incomplete pack ending at a clean frame boundary keeps clone's existing LBR-NET-001 transfer error and network retry hint. Fetch and pull report that completeness failure as LBR-NET-002.

Git and SSH advertisement frame boundaries

The Git/SSH pkt-line advertisement readers reject declared lengths 0001 through 0003, incomplete four-byte headers, and EOF inside a declared payload. Flush 0000, empty-payload 0004 and maximum-size ffff frames retain their behavior. Their typed pkt-line errors classify as LBR-NET-002 at the reader boundary; ordinary transport IO and idle timeouts remain LBR-NET-001 when classified.

During the git:// object-fetch advertisement, fetch, clone and pull already report these failures as LBR-NET-002, including a zero-byte advertisement. The hint is check that the remote serves Git data and that a proxy has not altered the response. Lengths 1–3 previously could panic; truncated advertisements previously returned LBR-NET-001 with a network/transfer hint. Git discovery now preserves these protocol errors through the command boundary. SSH propagation and bounded cleanup are described below. All readers require four ASCII hexadecimal header digits.

This advertisement is distinct from an upload-pack response after negotiation: HTTP(S) discovery framing and empty upload-pack response classifications are unchanged. Reader tests exercise local TCP object-fetch advertisements and public error conversions. Separate command tests exercise malformed Git discovery and SSH cleanup. Check the remote Git service or proxy for malformed frames.

SSH advertisement error handling

SSH advertisement lengths 0001 through 0003, incomplete headers (including zero-byte EOF), and truncated payloads return LBR-NET-002. The fixed protocol reason and marker are retained without captured SSH stdout/stderr.

An incomplete required discovery header has two prioritized exceptions. A recognized host-key diagnostic with local SSH exit status 255 returns fixed verification guidance and LBR-NET-001; this does not verify the remote fingerprint. A complete Permission denied (<method-list>) diagnostic containing the exact publickey method, direct exit status 255 and no stdout bytes returns the fixed public-key message with LBR-AUTH-002. Because stderr can be forged, this code does not prove why access was denied. All other missing advertisements remain LBR-NET-002, and original SSH diagnostic text is hidden.

After an incomplete required header, Libra allows up to 100 milliseconds to observe the SSH exit status, then requests termination if needed. Other read errors request termination immediately. The status window, direct-child reap and output collection share a two-second cleanup deadline. Protocol, typed host-trust, and public-key authentication errors take precedence over secondary cleanup warnings. Ordinary IO and timeout errors keep their transport classification and may include a fixed local cleanup warning. Termination can change the observed exit status. This does not promise cleanup of arbitrary descendant processes.

Clone places targeted host-verification guidance in its structured hints. The other command boundaries retain fixed host guidance in the message and their existing LBR-NET-001 network hint. Human, JSON and machine diagnostics omit raw captured remote stderr in either case.

The git:// discovery and object-fetch paths preserve the listed frame errors as LBR-NET-002. All asynchronous readers reject non-ASCII/non-hexadecimal headers with fixed protocol reasons. HTTP(S) discovery/advertisement framing is unchanged.

SSH authentication and captured diagnostics

Libra invokes SSH with BatchMode=yes for non-interactive, non-TTY, JSON and machine callers. In a human terminal with an effective ask policy (ssh.strictHostKeyChecking unset or ask), a first connection to an unknown SSH host shows a Git-compatible fingerprint confirmation prompt; accepting it writes the host key to your OpenSSH known-hosts destination and the original command continues, while rejecting, EOF or a changed host key fails closed. Libra never prompts for a private-key passphrase - load or unlock an encrypted key in ssh-agent before retrying. For host trust, verify the fingerprint through a trusted provider console or another trusted channel before manually updating ~/.ssh/known_hosts, or make a separate interactive SSH connection and compare the displayed fingerprint. For example, ssh -T git@github.com uses GitHub; use the actual repository SSH user, host and port. Do not accept a fingerprint that has not been verified.

For the strict discovery-only public-key rejection above, the fixed hint asks you to check libra config list --ssh-keys, your SSH agent and repository access, and links the SSH setup guide. libra config list --ssh-keys requires an existing Libra repository; before a clone creates one, inspect your SSH configuration and agent directly.

For at least 30 days after v0.24.1 is released and through at least the next patch release, whichever is later, automation should accept both LBR-AUTH-002 and the legacy LBR-NET-002 for this SSH discovery failure.

ssh.strictHostKeyChecking retains its existing ask, yes, accept-new and no values. The effective policy is resolved in precedence order: a non-empty LIBRA_SSH_STRICT_HOST_KEY_CHECKING environment variable, then local ssh.strictHostKeyChecking, then global, then system, then the default ask. Because a clone starts outside any repository, an explicit global or system policy is honored before the default ask takes over. ask leaves that SSH option to the user's SSH configuration; BatchMode=yes still prevents interactive decisions. Explicit values are forwarded to SSH. Choose a host-trust policy appropriate to your repository.

SSH stderr is always captured, including in terminal sessions. It is drained from process startup, retaining at most 64 KiB while counting and hashing the remaining bytes. User-facing errors contain fixed text and a local exit status when available. Raw remote stderr is neither printed nor logged. Debug diagnostics contain only the status, total and retained byte counts, and a SHA-256 digest of the collected stream. Failed or cancelled collection may prevent these metadata from being reported; no completed digest is claimed in that case. Hashing work is proportional to the number of bytes drained.

SSH reference advertisements and receive-pack responses each have a 16 MiB aggregate limit. An oversized advertisement fails with LBR-NET-001 and guidance to use the repository’s HTTPS URL if available, or ask its maintainer to reduce refs. An oversized push response fails with LBR-NET-001 and guidance to push fewer refs; it is not accepted as a truncated success. These limits can affect repositories with very large ref sets or updates. The streamed fetch pack is not subject to this cap. A failed push response does not prove that the server rolled back its refs: inspect the remote state before retrying. Existing IO timeouts still apply.

After a complete discovery advertisement, Libra allows up to 100 milliseconds for SSH to exit before requesting termination, within a two-second total cleanup deadline. Captured-output tasks are cancelled when their owner exits or their deadline expires, including when a descendant keeps a pipe open.

SSH host identity and diagnostic collection

SSH host identity changes retain a distinct fixed warning: the change may indicate interception or legitimate key rotation. Verify the new fingerprint through a trusted channel before replacing an existing known_hosts entry; do not bypass host-key checking. Unknown and changed host keys both use LBR-NET-001, but their fixed messages and guidance differ.

A stderr collection timeout does not by itself discard complete protocol output and an observed local exit status. Non-zero exit status and primary read errors still fail the operation. Unavailable diagnostics produce only a fixed debug notice, without fabricated empty-stream counts or digests. Stdout collection or process-wait failures retain their normal error handling.

SSH limits and host-classification boundaries

These fixed 16 MiB advertisement and receive-pack response limits apply only to Libra's SSH transport. The HTTPS and Git transports do not impose this particular cap. If the server provides an HTTPS endpoint, use its HTTPS remote URL when an SSH advertisement exceeds the cap; this does not require a read-only user to change the server's refs. Otherwise, ask the repository maintainer to reduce the advertised ref set. The streamed fetch pack remains outside this aggregate cap.

Host-trust classification requires an incomplete first header with no stdout bytes observed, local exit 255 and a recognized retained stderr pattern. Once any stdout byte arrives, including a partial header, host-like stderr cannot select host-specific guidance. Failures after a complete advertisement retain fixed generic diagnostics. The pre-advertisement pattern remains a diagnostic heuristic, not fingerprint verification.

A successful discovery whose child waits for a request normally incurs the full 100 ms native-exit observation window, once per discovery operation. This is separate from the two-second direct-child cleanup budget; no benchmark or arbitrary-descendant cleanup guarantee is implied.

Strict pkt-line headers

A pkt-line header must contain exactly four ASCII hexadecimal digits (0–9, a–f or A–F). Fetch streaming, git:// advertisements and SSH advertisements reject leading signs such as +004, whitespace, non-hexadecimal text and invalid UTF-8. These failures return LBR-NET-002 (exit 128), with fixed reasons that do not echo the header or payload. A peer that previously sent a signed or otherwise nonconforming header must send four hexadecimal digits before retrying.

Git discovery also preserves protocol classification for lengths 0001–0003, missing or partial required headers and truncated payloads. The same discovery classification reaches clone, fetch, pull, ls-remote and push. Check the remote Git service or proxy response. Their existing structured error fields remain; push retains its own protocol hint and the other commands retain theirs.

Flush 0000, empty-data 0004 and maximum-length ffff frames keep their existing meaning. Ordinary network errors and timeouts retain their existing categories. An empty fetch data stream before any complete pack remains a network failure; EOF after a completed pack keeps the existing success behavior. The SSH host-trust exception, captured-diagnostic limits and cleanup deadlines described above remain.

Empty-repository discovery framing

An HTTP(S) advertisement that declares an empty repository still has all remaining pkt-line frames checked. A malformed header, an unsupported length 1..3, or a truncated payload after the zero object ID returns LBR-NET-002 (exit 128), with a fixed reason that does not echo the remote bytes. It is no longer reported as a successful empty response. Check the remote Git service or proxy response before retrying. Valid empty repositories, supported SHA-1/SHA-256 advertisements, existing command hints and structured error fields retain their behavior.