git log --stat 相对于子文件夹

git log --stat relative to subfolder

我想显示 git log --stat 中相对于某个子文件夹的文件名,以便于阅读。我该怎么做?

我尝试了 git log --stat sub/folder/foogit log --stat sub/folder/foo/,并更改到 运行、git log --statgit log --stat .git log --stat ./ 之前的子文件夹。

使用--relative:

--relative[=<path>]

When run from a subdirectory of the project, it can be told to exclude changes outside the directory and show pathnames relative to it with this option. When you are not in a subdirectory (e.g. in a bare repository), you can name which subdirectory to make the output relative to by giving a <path> as an argument.

您可以发出命令 git whatchanged --relative 来准确给出您想要的。

对于 spec 文件夹,它将像这样列出,例如:

commit 0e1efda06b940d0b675a45884bc379bfb77537eb
Author: Andrew Grimm <andrew.j.grimm@gmail.com>
Date:   Fri Apr 24 23:42:44 2015 +1000

    Fix broken spec fixtures

:100644 100644 f6d6ef0... 2ae6d82... M  spec/factories/pmc_article_factory.rb
:100644 100644 bc30bfb... ecb98c9... M  spec/factories/pmc_article_list_factory.rb

commit fe77bd9fac39f6abcd4e19fac39d69cb64582f7e
Author: Andrew Grimm <andrew.j.grimm@gmail.com>
Date:   Fri Apr 10 19:31:25 2015 +1000

    Squash all commits for the repo, because of wrong email being used.

:000000 100644 0000000... 4bb2e7c... A  spec/affiliation_words_query_spec.rb
:000000 100644 0000000... f6d6ef0... A  spec/factories/pmc_article_factory.rb
:000000 100644 0000000... bc30bfb... A  spec/factories/pmc_article_list_factory.rb
:000000 100644 0000000... d23c1d9... A  spec/frequent_names_runner_spec.rb
:000000 100644 0000000... 5e48c86... A  spec/pmc_article_spec.rb
:000000 100644 0000000... b598abe... A  spec/spec_helper.rb
:000000 100644 0000000... eec437f... A  spec/support/factory_girl.rb