如何在git blame时抑制--show-name(filename)选项?

Fra*_*ang 10 git

-f, --show-name
       Show the filename in the original commit. By default the filename is shown if there is any line that came from a file with a different name, due to rename detection.
Run Code Online (Sandbox Code Playgroud)

但是--show-name=off不起作用.

error: option `show-name' takes no value
usage: git blame [<options>] [<rev-opts>] [<rev>] [--] <file>
Run Code Online (Sandbox Code Playgroud)

如何从输出中隐藏详细文件名?

Von*_*onC 7

此选项在commit eb93b724中引入(git 1.4.4,2006年10月)

新选项使命令的本机输出格式显示文件名,即使其历史记录中没有重命名,也使Porcelains解析其输出更简单.

这意味着:

  • 不使用此选项是让它"关闭"的方法
  • 如果历史记录中存在重命名,则始终显示文件名.

正如Edouard Poor的回答所提到的,你可以使用git blame -c,它强制使用相同的输出模式git-annotate.


Mat*_*nry 5

git annotate不在其输出中包含此信息。(--show-name如果您尝试激活它,它会默默地忽略该选项。)


Edo*_*oor 5

正如马特麦克亨利所说,git annotate不显示文件名。

诀窍是git blame采用一个-c标志来强制输出符合 annotate 子命令,这会导致没有文件名。