我如何打印一份包含所有提交文件的简单列表?

尽管下面列出了这些文件,但它也包含了每个文件不需要的差异信息:

git show a303aa90779efdd2f6b9d90693e2cbbbe4613c1d

当前回答

我喜欢这样:

git diff --name-status <SHA1> <SHA1>^

其他回答

显示日志。

COMMIT可以是空白(“”)、SHA-1哈希或SHA-1哈希的缩短版本。

git log COMMIT -1 --name-only

这将仅列出文件,对进一步处理非常有用。

git log COMMIT -1 --name-only --pretty=format:"" | grep "[^\s]"

我只是假设gitk不适合这样做。在这种情况下,请尝试git show--name only<sha>。

只有文件列表(甚至没有提交消息):

git show --name-only --pretty=format:

例如,在编辑器中打开所有更改的文件:

git show --name-only --pretty=format: | xargs "$EDITOR"

你也可以

git log --name-only

您可以浏览各种提交、提交消息和更改的文件。

键入q以返回提示。

首选方式(因为它是管道命令;意在编程):

$ git diff-tree --no-commit-id --name-only bd61ad98 -r
index.html
javascript/application.js
javascript/ie6.js

另一种方式(不太适合脚本,因为它是一个瓷命令;意味着面向用户)

$ git show --pretty="" --name-only bd61ad98    
index.html
javascript/application.js
javascript/ie6.js

--no提交id将抑制提交id输出。--prey参数指定了一个空格式字符串,以避免开头的错误。--name only参数仅显示受影响的文件名(Thanks Hank)。如果您想查看每个文件(已删除、已修改、已添加)的情况,请改用--name status-r参数用于递归到子树中