LibraLibra
LibraLibra
DocsBlogLibra
Getting Started
Architecture
Design
Commands
libra addlibra agentlibra alternateslibra applylibra archivelibra authlibra automationlibra bisectlibra blamelibra branchlibra bundlelibra cachelibra cat-filelibra check-attrlibra check-ignorelibra check-mailmaplibra checkoutlibra cherry-picklibra cleanlibra clonelibra cloudlibra code-controllibra codelibra commit-treelibra commitlibra completionslibra configlibra credentiallibra depslibra describelibra diff-fileslibra diff-indexlibra diff-treelibra difflibra dirtylibra fast-exportlibra fast-importlibra fetchlibra filelibra for-each-reflibra format-patchlibra fscklibra gclibra graphlibra greplibra hash-objectlibra hookslibra hydratelibra index-packlibra initlibra investigatelibra layerlibra lfslibra loglibra logfilelibra loginlibra logoutlibra ls-fileslibra ls-remotelibra ls-treelibra maintenancelibra medialibra merge-baselibra merge-filelibra mergelibra metadatalibra mvlibra noteslibra oplibra openlibra pack-objectslibra packagelibra prunelibra publishlibra pulllibra pushlibra read-treelibra rebaselibra refloglibra remotelibra repacklibra replacelibra rererelibra resetlibra restorelibra rev-listlibra rev-parselibra revertlibra reviewlibra revisionlibra rmlibra sandboxlibra servicelibra shortloglibra show-reflibra showlibra sparse-viewlibra stashlibra statslibra statuslibra switchlibra symbolic-reflibra taglibra update-indexlibra update-reflibra usagelibra verify-packlibra whoamilibra worktreelibra write-tree
API Reference
Policy
Commands

libra update-index

Command reference for `libra update-index`

Modify the index directly — a focused subset of git update-index. The companion to write-tree: --cacheinfo registers an index entry from an object id without reading the working tree, so an index can be built purely from objects.

Synopsis

libra update-index --add <path>...
libra update-index --remove <path>...
libra update-index --cacheinfo <mode>,<object>,<path>...

Description

update-index applies, in order: every --cacheinfo entry, then the positional paths (removed with --remove, otherwise (re)staged from the working tree), and saves the index.

  • --cacheinfo <mode>,<object>,<path> inserts/updates an entry directly. The object need not exist yet (matching Git), so you can build an index from hashes computed with hash-object. <mode> is an octal file mode: 100644 (file), 100755 (executable), 120000 (symlink), 160000 (gitlink). The object id length must match the repository hash format. The path is an index key — absolute paths and .. traversal are rejected.
  • --add <path>... (re)stages files from the working tree, allowing paths not yet tracked. Without --add, a positional path must already be tracked.
  • --remove <path>... drops the named paths from the index.

Options

OptionDescriptionExample
--addAllow positional paths to add new (untracked) files.libra update-index --add a.txt
--removeRemove the positional paths from the index.libra update-index --remove old.txt
--cacheinfo <mode>,<object>,<path>Register an entry from an object id (repeatable).libra update-index --cacheinfo 100644,<oid>,dir/f.txt
--json / --machineStructured output: { updated: <n>, removed: <n> }.libra --json update-index --add a.txt

Exit codes

CodeMeaning
0The index was updated and saved.
128Not inside a repository, a usage error (bad --cacheinfo, untracked path without --add), or a missing working-tree file.

Examples

# Build an index entry from an object id, then write the tree
OID=$(libra hash-object -w data.bin)
libra update-index --cacheinfo 100644,"$OID",assets/data.bin
libra write-tree

# Stage and unstage working-tree files
libra update-index --add src/new.rs
libra update-index --remove src/old.rs

Comparison with Git

TaskLibraGit
Stage a filelibra update-index --add fgit update-index --add f
Remove a pathlibra update-index --remove fgit update-index --remove f
Register by idlibra update-index --cacheinfo m,oid,pgit update-index --cacheinfo m,oid,p

Deferred (not exposed): bare-path stat refresh, --force-remove, --chmod, --assume-unchanged, --skip-worktree, --index-info, and other Git flags.

libra tag

Command reference for `libra tag`

libra update-ref

Command reference for `libra update-ref`

On this page

SynopsisDescriptionOptionsExit codesExamplesComparison with Git