Ответ 1
Вы ищете git read-tree -um
дерево git read-tree -um
. Он использует базовое дерево (обычно вы его загружаете HEAD
), целевое дерево и (неявно) индекс и worktree. Таблицу, описывающую ее поведение, было трудно понять, поэтому у меня есть своя чит-карта для нее, переформатированная, которая имеет для меня больше смысла. Во всяком случае, он реализует git checkout
.
git read-tree -um H M # 'I' is the (implicit) index, GIT_INDEX_FILE
Legend
H Original tree (usually HEAD:)
I Indexed tree
M Merge target tree
H->I \
H->M } status in second relative to first
I->M /
"-" file exists in neither
new exists only in second
deleted exists only in first
same exists in both, unchanged
changed exists in both, different
(blank) irrelevant or all cases not otherwise given
keep keep current version
fail whole command fails, no changes
delete delete worktree file
H->I H->M I->M
same keep
deleted changed fail
deleted deleted delete
deleted same delete unless Index empty, else use M
same keep
same changed worktree clean: use M; dirty: fail
same deleted worktree clean: deleted; dirty: fail
new - keep
new new changed fail
changed changed changed fail
changed deleted fail
note: "index empty" identifies an initial checkout, where HEAD has been
set but never loaded. git can't currently distinguish between a
delete-everything index and an initial-checkout index.