What flags need to be set on `git log` to make it have similar output to `git whatchanged`?

有些话、适合烂在心里 提交于 2019-12-22 08:19:36

问题


Per: Difference between git-log and git-whatchanged?

Encourage new users to use 'log' instead. These days, these commands are unified and just have different defaults.

I only recently discovered git whatchanged but found its output:

commit deadbeefdeadbeefdeadbeefdeadbeefdeadbeef
Author: Egg Sample <mail@example.com>
Date: Mon Jan 28 16:32:04 2019 -0800

    change some files

:100777 100644 abaddad1 feeb1e42 M      src/changemymode.txt
:100644 100644 1234abcd abcd1234 M      src/changemycontent.txt
:000000 100755 00000000 6600abcd A      src/addme.txt
:100755 000000 feed1bee 00000000 D      src/deleteme.txt

useful for a particular workflow I had recently (involving a branch with many file mode changes). Out of curiosity, what would I need to do to make git log behave in such a manner, i.e.:

  • show the commit information,
  • the old mode, new mode, hashes, Modified|Added|Deleted and filenames of the files that changed
  • and not the diffs themselves
  • (and exclude merges by default, which is also called out as git whatchanged behavior).

I figured it might be something in the --stat or --format options, but git log --help doesn't seem to mention anything about getting the file modes and object hashes printed in conjunction with these options, and a quick scan of said document doesn't have anything jump out at me.


回答1:


Just so this question is not left unanswered:

By this revised answer, newer versions of git explain this on man git-whatchanged

The whatchanged command is essentially the same as git-log(1) but defaults to show the raw format diff output and to skip merges.

So:

git log --raw --no-merges


来源:https://stackoverflow.com/questions/54412432/what-flags-need-to-be-set-on-git-log-to-make-it-have-similar-output-to-git-wh

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