How to make git log show file paths relative to current directory?

三世轮回 提交于 2019-12-03 16:43:07

In order to use the paths in the output of git log --name-only, add the option --git-dir to git diff.

git --git-dir="$(git rev-parse --show-toplevel)"/.git diff HEAD~ child_dir1_from_root/file1

For easy use, make an alias in the config.

[alias]
        mdiff = "! git --git-dir=\"$(git rev-parse --show-toplevel)\"/.git diff"

git mdiff HEAD~ child_dir1_from_root/file1 now can work as long as the current directory belongs to the working tree.

You can add up the --relative='PATH' to the subdirectory you want.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!