GIT-READ-TREE(1) (NAME) git-read-tree - (SYNOPSIS) git read-tree [(-[--rivial] [--ggressive] | --eset | --refix=) [-u | -i]] [--index-output=] [--0-sparse-checkout] (--\mpty | [ []]) (DESCRIPTION) (index) "" . (: git-checkout-index(1)) -m ( -) - . -m -u (work tree) . (trivial merges) git read-tree . git read-tree (unmerged) . (OPTIONS) -m . ( ) . --eset -m . -u . -u . -i head . . -n, --ry-run . -v . --rivial git read-tree . --ggressive git read-tree (porcelains) . : o . . o . . o . . --refix= tree-ish . . --index-output= $GIT_INDEX_FILE . . (rename(2)) . --ecurse-submodules, --0-recurse-submodules --ecurse-submodules (superproject) read-tree HEAD (detached) . --0-sparse-checkout (sparse checkout) core.sparseCheckout true . --\mpty () . -q, --quiet . () . (MERGING) -m git read-tree : - . Single Tree Merge git read-tree -m stat . ( stat() ). git read-tree -m git checkout-index -f -u -a git checkout-index . git diff-files git read-tree . Two Tree Merge git read-tree -m $H $M H$ head M$ H$ ( fast-forward ). git read-tree : 1. H$ H$ . 2. M$ (fast-forward) . git read-tree -m $H $M "" . " " "I" "clean" "exists"/"nothing" : I H M Result ------------------------------------------------------- 0 nothing nothing nothing (does not happen) 1 nothing nothing exists use M 2 nothing exists nothing remove path from index 3 nothing exists exists, use M if "initial checkout", H == M keep index otherwise exists, fail H != M clean I==H I==M ------------------ 4 yes N/A N/A nothing nothing keep index 5 no N/A N/A nothing nothing keep index 6 yes N/A yes nothing exists keep index 7 no N/A yes nothing exists keep index 8 yes N/A no nothing exists fail 9 no N/A no nothing exists fail 10 yes yes N/A exists nothing remove path from index 11 no yes N/A exists nothing fail 12 yes no N/A exists nothing fail 13 no no N/A exists nothing fail clean (H==M) ------ 14 yes exists exists keep index 15 no exists exists keep index clean I==H I==M (H!=M) ------------------ 16 yes no no exists exists fail 17 no no no exists exists fail 18 yes no yes exists exists keep index 19 no no yes exists exists keep index 20 yes yes no exists exists use M 21 no yes no exists exists fail "keep index" . git read-tree u- . git read-tree git diff-index --ached $M " " . git diff-index --ached $H . -- M$ ( ) git diff-index --ached $H git diff-index --ached $M . . (stage) . M ( ) . H$ M$ . 3-Way Merge "" "" (stage) . . git read-tree "" . : $ git read-tree -m "stage1" "stage2" "stage3" . . git read-tree : "stage0" : o ( - ) o ( ) o ( ) git write-tree . . " " ( "merged") ( "orig") ( ). ( ) - . : o git read-tree "merged" . o . " " (porcelain policy) . o // ( " ") . : o . o "stage1" "stage2" "stage3" ( ) . o "stage2" "stage3" "stage0" . "stage1" . .. .. git merge-index git merge-one-file . . - . " " . - . . : $ JC=`git rev-parse -- $ git checkout-index -f -u -a $JC git update-index . "" (upstream) pull : $ git fetch git://.... linus $ LT=`git rev-parse FETCH_HEAD` HEAD ($JC) . $JC . : $ git read-tree -m -u `git merge-base $JC $LT` $JC $LT $ git merge-index git-merge-one-file -a $ echo "Merge with Linus" | \ git commit-tree `git write-tree` -p $JC -p $LT $JC $LT . git read-tree . . . (git read-tree ). ( ) . (SPARSE CHECKOUT) : skip-worktree git- update-index(1) read-tree git-sparse-checkout(1) . /skip-worktree (plumbing) sparse-checkout . (non-cone mode) sparse-checkout . " " . skip-worktree ( git-update- index(1) ) . git read-tree (git merge git checkout ) skip-worktree . $GIT_DIR/info/sparse-checkout skip-worktree . git read-tree skip-worktree ( gitignore. ) . skip-worktree . skip-worktree . skip-worktree . skip-worktree . . $GIT_DIR/info/sparse-checkout . unwanted: /* !unwanted . " " skip-worktree . $GIT_DIR/info/sparse-checkout : /* . git read-tree . core.sparseCheckout . (SEE ALSO) git-write-tree(1), git-ls-files(1), gitignore(5), git-sparse- checkout(1) (GIT) git(1) Git 2.55.0 2026-06-29 GIT-READ-TREE(1)