Git log to show commits either by author OR commit message

那年仲夏 提交于 2021-01-27 14:40:30

问题


I would like to use git log (open to other suggestions) to list all commits that either

  • Were done by a specific author

or

  • Which have a specific word in their commit message

I know how to search for each separately, but I would like a single list containing all matching commits. What is the easiest way to achieve this?


回答1:


You can use git rev-list to generate the hash IDs that git log should show, and then use git log --no-walk --stdin to read those IDs, sort them according to the usual git log sorting criteria, and show them. (Note: This will occasionally change the output order from what you would see with git log without --no-walk.)

For instance:

(git rev-list --author 'A. U. Thor' HEAD;
 git rev-list --grep 'pattern' HEAD) |
git log --no-walk --stdin

(split into three lines for posting purposes; some command line interpreters will require that the command be a single line when actually used).



来源:https://stackoverflow.com/questions/48215421/git-log-to-show-commits-either-by-author-or-commit-message

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