如何一次为作者从所有分支进行 git log 记录?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10349302/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 13:34:17  来源:igfitidea点击:

How to git log from all branches for the author at once?

git

提问by pepr

I need to get the report of all commits that the author did. So far, I have the script that wraps the following command:

我需要获得作者所做的所有提交的报告。到目前为止,我有包装以下命令的脚本:

git log --pretty=format:"%ad:%an:%d:%B" --date=short --reverse --all --since=2.months.ago --author=Petr

It works fine. However, it reports only the actions for the current branch. Is there any option that would log the commit messages for the author from all branches, not only form the current one?

它工作正常。但是,它仅报告当前分支的操作​​。是否有任何选项可以记录来自所有分支的作者的提交消息,而不仅仅是形成当前分支

In other words, can git make a reverse sorted (by datetime) sequence of all the commits in repository and extract the log info from that sequence?

换句话说,git 是否可以对存储库中的所有提交进行反向排序(按日期时间)序列并从该序列中提取日志信息?

Solved:(copied from the comment below that is hidden otherwise)

已解决:(从下面的评论中复制,否则隐藏)

The problem was that I have one repository and two clones to work concurently on two branches. I did push the changes to the origin repository, but I forgot to fetch the changes to the cloned repository. This way it seemed that --alldid not work when using it for the cloned repository.

问题是我有一个存储库和两个克隆可以在两个分支上同时工作。我确实将更改推送到原始存储库,但我忘记将更改获取到克隆存储库。这样--all在将它用于克隆的存储库时似乎不起作用。

采纳答案by CharlesB

Your command is right, since you use the --allswitch which gives all commits from all branches. To answer the question in your comment, it works also in bare repositories.

您的命令是正确的,因为您使用了--all从所有分支提供所有提交的开关。要回答您评论中的问题,它也适用于裸存储库。

回答by Gert Hengeveld

Instead of --allyou may want to use --branches, since --allalso includes refs/tagsand refs/remotes.

而不是--all您可能想要使用--branches,因为--all还包括refs/tagsrefs/remotes