如何列出一次提交中的所有文件 [英] How to list all the files in a commit
问题描述
我正在寻找一个简单的Git命令,该命令将提供格式良好的所有文件列表,这些文件是哈希(SHA-1)所提交的提交的一部分,而没有多余的信息.
I am looking for a simple Git command that provides a nicely formatted list of all files that were part of the commit given by a hash (SHA-1), with no extraneous information.
我尝试过:
git show a303aa90779efdd2f6b9d90693e2cbbbe4613c1d
尽管列出了文件,但每个文件都包含不需要的差异信息.
Although it lists the files, it also includes unwanted diff information for each.
是否还有另一个 git
命令将仅提供我想要的列表,以便避免从 git show
输出中对其进行解析?
Is there another git
command that will provide just the list I want, so that I can avoid parsing it from the git show
output?
推荐答案
首选方式(因为它是 plumbing 命令;本来是编程性的):
Preferred Way (because it's a plumbing command; meant to be programmatic):
$ git diff-tree --no-commit-id --name-only -r bd61ad98
index.html
javascript/application.js
javascript/ie6.js
另一种方式(由于它是 porcelain 命令;本来是面向用户的,因此脚本不那么受欢迎)
Another Way (less preferred for scripts, because it's a porcelain command; meant to be user-facing)
$ git show --pretty="" --name-only bd61ad98
index.html
javascript/application.js
javascript/ie6.js
-
-no-commit-id
禁止提交提交ID. -
-pretty
参数指定一个空的格式字符串,以避免开头出现压缩现象. -
-仅名称
参数仅显示受影响的文件名(感谢Hank).如果要查看每个文件发生了什么( D 已删除, M 已修改, A ddd) -
-r
参数将递归到子树 - The
--no-commit-id
suppresses the commit ID output. - The
--pretty
argument specifies an empty format string to avoid the cruft at the beginning. - The
--name-only
argument shows only the file names that were affected (Thanks Hank). Use--name-status
instead, if you want to see what happened to each file (Deleted, Modified, Added) - The
-r
argument is to recurse into sub-trees
这篇关于如何列出一次提交中的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!