Search code examples
gitgit-log

git log --stat relative to subfolder


I want to display the filenames in git log --stat relative to a certain sub-folder, so that it's easier to read. How can I do this?

I tried git log --stat sub/folder/foo, git log --stat sub/folder/foo/, and changing to the subfolder before running git log --stat, git log --stat ., and git log --stat ./.


Solution

  • Use --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.