git-merge-index
Resolve git merge conflicts
TLDR
Merge all files needing resolution using the standard helper
Merge a specific file
Merge multiple files, continuing on failures
Quietly merge all files with a custom program
Inspect merge inputs for a file using cat
SYNOPSIS
git merge-index [-o] [-q] [--] <merge-script> [<filename>…]
PARAMETERS
-o, --overlap
Run merge-script on all index files, even unmodified ones (highly recommended for scripts unable to detect success)
-q, --quiet
Suppress complaints about files not present or needing no merge (default since Git 2.41)
DESCRIPTION
git merge-index is a low-level Git plumbing command designed to execute a custom merge script across multiple files in the Git index that require merging, typically those with conflicts (stage > 0 entries).
It provides a simple multi-file interface similar to git-merge-one-file, passing each affected file's three versions (ancestor, current branch, other branch) as temporary files to the specified merge-script. The script receives arguments in the form merge-script $path1 $path2 $path3, where paths point to stage 1, 2, and 3 blobs.
This command is rarely used directly by end-users today, as modern Git prefers declarative merge drivers configured via gitattributes. However, it remains useful for custom workflows or legacy scripts handling specialized merge logic, such as for binary files or non-text merges. It processes files listed explicitly or all conflicted ones if no filenames are given.
Upon completion, it updates the index based on the script's exit status: success (0) stages the result in slot 0; failure (>0) leaves conflicts unresolved.
CAVEATS
Low-level plumbing command; use merge drivers instead for new code. Scripts must handle cleanup of temp files and return 0 on success to resolve index entries.
TYPICAL USAGE
git merge-index git-merge-one-file -a resolves all conflicted files using Git's default one-file merger.
git merge-index -o mymergescript foo bar applies custom script to specific files.
EXIT STATUS
0 if all merges succeeded; non-zero if any script failed or errors occurred.
HISTORY
Introduced in early Git (v1.0.4, 2005) by Linus Torvalds as part of core merge infrastructure; evolved with index staging but largely superseded by attribute-based drivers in Git 1.7+.
SEE ALSO
git-merge(1), git-merge-file(1), git-merge-tree(1), gitattributes(5)


