← 返回命令列表

Linux command

git-read-tree 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Read tree into index

git read-tree [tree-ish]

Merge trees

git read-tree -m [base] [ours] [theirs]

Read with prefix

git read-tree --prefix=[dir/] [tree-ish]

Merge and update working tree

git read-tree -m -u [base] [ours] [theirs]

Reset index

git read-tree --reset HEAD

Empty the index

git read-tree --empty

Dry run to check for errors

git read-tree -n -m [tree-ish]

说明

git read-tree reads tree information into the index. It is a plumbing command used internally by porcelain commands like `git checkout` and `git merge` to manipulate the staging area. The command can read a single tree or perform three-way merges of trees. It updates the index without touching the working tree unless the `-u` flag is specified to synchronize the working directory.

参数

-m
Merge mode.
-u
Update working tree.
--reset
Same as -m, discard unmerged.
--prefix=_DIR/_
Keep current index contents and read tree into subdirectory at prefix.
-i
Only update index, do not check working tree for consistency with current head.
-n, --dry-run
Check for errors without updating the index or working tree.
-v
Show progress of checking files out.
--trivial
Only perform merge for trivial cases, leave conflicts unresolved.
--aggressive
Resolve more cases internally during three-way merge.
--index-output _FILE_
Write results to specified file instead of $GIT_INDEX_FILE.
--empty
Instead of reading tree into the index, empty it.
--no-sparse-checkout
Disable sparse checkout support even if core.sparseCheckout is true.
--help
Display help information.

FAQ

What is the git-read-tree command used for?

git read-tree reads tree information into the index. It is a plumbing command used internally by porcelain commands like `git checkout` and `git merge` to manipulate the staging area. The command can read a single tree or perform three-way merges of trees. It updates the index without touching the working tree unless the `-u` flag is specified to synchronize the working directory.

How do I run a basic git-read-tree example?

Run `git read-tree [tree-ish]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -m do in git-read-tree?

Merge mode.