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 merge-file

Command reference for `libra merge-file`

Run a file-level three-way merge — a focused subset of git merge-file. Merges <current> and <other> relative to their common ancestor <base>, using the same diffy three-way merge that libra merge uses for blob contents, so the conflict markers are identical.

Synopsis

libra merge-file [-p|--stdout] [--diff3] [-q|--quiet] <current> <base> <other>

Description

merge-file incorporates the changes that lead from <base> to <other> into <current>. Where both sides changed the same lines, a conflict is recorded with markers:

<<<<<<< ours
...lines from <current>...
=======
...lines from <other>...
>>>>>>> theirs

With --diff3, the base section is included between ||||||| and =======.

By default the result is written back into <current>; with -p it is printed to stdout and no file is touched. When writing in place inside a repository, the original <current> is first copied to .libra/merge-file-backup/; the backup is removed on a clean merge and kept (with a note) when conflicts remain.

The three arguments are read as raw bytes; merge-file does not require them to be tracked or to correspond to stored blobs.

Options

OptionDescriptionExample
-p, --stdoutPrint the merged result to stdout; do not modify <current>.libra merge-file -p a b c
--diff3Include the <base> section in conflict markers.libra merge-file --diff3 -p a b c
-q, --quietDo not warn about conflicts on stderr.libra merge-file -q a b c
--json / --machineStructured output: { conflict, written, merged? } (merged only with -p).libra --json merge-file -p a b c

Exit codes

CodeMeaning
0Clean merge (no conflicts).
1The merge produced conflicts (markers are still emitted). Fixed at 1 regardless of the number of conflicts.
128Error: a missing/unreadable input, or a binary file (a NUL byte was found).

Examples

# Print a merged result without touching any file
libra merge-file -p ours.txt base.txt theirs.txt

# Merge in place into ours.txt (backed up under .libra/merge-file-backup/)
libra merge-file ours.txt base.txt theirs.txt

# diff3-style markers that also show the common ancestor
libra merge-file --diff3 -p ours.txt base.txt theirs.txt

Comparison with Git

TaskLibraGit
Three-way merge to stdoutlibra merge-file -p a b cgit merge-file -p a b c
Merge in placelibra merge-file a b cgit merge-file a b c
diff3 markerslibra merge-file --diff3 …git merge-file --diff3 …

Differences and deferred options: conflict markers are labelled ours / theirs (consistent with libra merge), not the file names; the conflict exit code is fixed at 1 (Git reports the conflict count); and -L <label>, --ours / --theirs / --union, and --marker-size are not yet exposed.

libra merge-base

Command reference for `libra merge-base`

libra merge

Command reference for `libra merge`

On this page

SynopsisDescriptionOptionsExit codesExamplesComparison with Git