← 返回命令列表

Linux command

git-mktree 命令

文件

涉及管道、覆盖或删除,执行前请先确认路径和参数。

常用示例

Create tree from ls-tree output

git ls-tree HEAD | git mktree

Create tree from file

git mktree < [tree-listing.txt]

Allow missing objects

git mktree --missing

说明

git mktree creates a tree object from ls-tree formatted input. It reads file modes, object types, hashes, and names from stdin, creating a new tree object containing those entries. The command is the inverse of `git ls-tree`. This plumbing tool enables programmatic tree creation and manipulation in scripts. Input must be properly formatted with each line specifying mode, type, hash, and filename.

参数

--missing
Allow missing objects.
-z
NUL-terminated input.
--batch
Process multiple trees.
--help
Display help information.

FAQ

What is the git-mktree command used for?

git mktree creates a tree object from ls-tree formatted input. It reads file modes, object types, hashes, and names from stdin, creating a new tree object containing those entries. The command is the inverse of `git ls-tree`. This plumbing tool enables programmatic tree creation and manipulation in scripts. Input must be properly formatted with each line specifying mode, type, hash, and filename.

How do I run a basic git-mktree example?

Run `git ls-tree HEAD | git mktree` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does --missing do in git-mktree?

Allow missing objects.