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

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

git show a303aa90779efdd2f6b9d90693e2cbbbe4613c1d

当前回答

还有gitwhatchanged,它比gitlog更低级

NAME
       git-whatchanged - Show logs with difference each commit introduces

它输出提交摘要,其中包含其下的文件列表及其模式,以及它们是否被添加(a)、删除(D)或修改(M);

$ git whatchanged f31a441398fb7834fde24c5b0c2974182a431363

会给出如下内容:

commit f31a441398fb7834fde24c5b0c2974182a431363
Author: xx <xx@xx.nl>
Date:   Tue Sep 29 17:23:22 2015 +0200

    added fb skd and XLForm

:000000 100644 0000000... 90a20d7... A  Pods/Bolts/Bolts/Common/BFCancellationToken.h
:000000 100644 0000000... b5006d0... A  Pods/Bolts/Bolts/Common/BFCancellationToken.m
:000000 100644 0000000... 3e7b711... A  Pods/Bolts/Bolts/Common/BFCancellationTokenRegistration.h
:000000 100644 0000000... 9c8a7ae... A  Pods/Bolts/Bolts/Common/BFCancellationTokenRegistration.m
:000000 100644 0000000... bd6e7a1... A  Pods/Bolts/Bolts/Common/BFCancellationTokenSource.h
:000000 100644 0000000... 947f725... A  Pods/Bolts/Bolts/Common/BFCancellationTokenSource.m
:000000 100644 0000000... cf7dcdf... A  Pods/Bolts/Bolts/Common/BFDefines.h
:000000 100644 0000000... 02af9ba... A  Pods/Bolts/Bolts/Common/BFExecutor.h
:000000 100644 0000000... 292e27c... A  Pods/Bolts/Bolts/Common/BFExecutor.m
:000000 100644 0000000... 827071d... A  Pods/Bolts/Bolts/Common/BFTask.h
...

我知道这个答案并不符合“没有无关信息”,但我仍然认为这个列表比文件名更有用。

其他回答

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

so:

git log -n3

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

git log -n3 --name-only

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

最近,我需要列出两次提交之间所有更改的文件。所以我使用了这个(也是*nix特定的)命令

git show --pretty="format:" --name-only START_COMMIT..END_COMMIT | sort | uniq

或者正如Ethan指出的:

git diff --name-only START_COMMIT..END_COMMIT

使用--name状态还将包括每个文件旁边的更改(添加、修改、删除等):

git diff --name-status START_COMMIT..END_COMMIT

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

$ 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 show HEAD@{0}

对我来说很好

尝试此命令获取名称并更改行数

git show --stat <commit-hash>

仅显示文件名

git show --stat --name-only  <commit-hash>

要获取最后一个提交哈希,请尝试以下命令:

git log -1

上次提交时显示文件名和文件状态修改、创建或删除:

 git log -1 --oneline --name-status <commit-hash>

或所有人

git log

有关更高级的git日志信息,请阅读以下文章:

Git日志格式字符串备忘单git日志备忘单