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

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

git show a303aa90779efdd2f6b9d90693e2cbbbe4613c1d

当前回答

我经常使用更改后的别名。要设置它,请执行以下操作:

git config --global alias.changed 'show --pretty="format:" --name-only'

然后:

git changed (lists files modified in last commit)
git changed bAda55 (lists files modified in this commit)
git changed bAda55..ff0021 (lists files modified between those commits)

可能有用的类似命令:

git log --name-status --oneline (very similar, but shows what actually happened M/C/D)
git show --name-only

其他回答

也许我错过了,有人提到过,如果您想使用“log”命令增加log x以前的提交,以包括受影响的文件的名称,然后在末尾添加--name。

so:

git log -n3

查看最后3次提交的最后评论。

git log -n3 --name-only

查看最近3次提交中生效的评论和文件。

我经常使用更改后的别名。要设置它,请执行以下操作:

git config --global alias.changed 'show --pretty="format:" --name-only'

然后:

git changed (lists files modified in last commit)
git changed bAda55 (lists files modified in this commit)
git changed bAda55..ff0021 (lists files modified between those commits)

可能有用的类似命令:

git log --name-status --oneline (very similar, but shows what actually happened M/C/D)
git show --name-only

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

$ 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参数用于递归到子树中

列出提交树中的所有文件:

git ls-tree --name-only --full-tree a21e610

“gitshow--stat”(谢谢Ryan)和几个sed命令的组合应该可以为您减少数据:

git show --stat <SHA1> | sed -n "/ [\w]\*|/p" | sed "s/|.\*$//"

这将只生成已修改文件的列表。