Linux command
git-diff-tree 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Compare two trees
git diff-tree [tree1] [tree2]
Show changes in commit
git diff-tree -p [commit]
Show changed files
git diff-tree --name-only [commit]
Raw output
git diff-tree --raw [commit]
说明
git diff-tree compares the content and mode of blobs found via two tree objects, providing low-level access to Git's internal tree comparison mechanism. This plumbing command forms the foundation for examining differences between commits, branches, or any tree-like structures in Git's object database. The command accepts one or two tree-ish arguments and outputs the differences in various formats. It can process commits via stdin, enabling efficient batch processing of history. While rarely needed in daily Git use, it underpins many higher-level operations and is essential for scripts and custom diff tools.
参数
- -r
- Recurse into subtrees.
- -p, --patch
- Generate patch.
- --raw
- Raw diff format.
- --name-only
- Show file names only.
- --name-status
- Show status and names.
- -s
- Suppress diff output.
- --stdin
- Read commits from stdin.
FAQ
What is the git-diff-tree command used for?
git diff-tree compares the content and mode of blobs found via two tree objects, providing low-level access to Git's internal tree comparison mechanism. This plumbing command forms the foundation for examining differences between commits, branches, or any tree-like structures in Git's object database. The command accepts one or two tree-ish arguments and outputs the differences in various formats. It can process commits via stdin, enabling efficient batch processing of history. While rarely needed in daily Git use, it underpins many higher-level operations and is essential for scripts and custom diff tools.
How do I run a basic git-diff-tree example?
Run `git diff-tree [tree1] [tree2]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -r do in git-diff-tree?
Recurse into subtrees.