在 Git 中列出项目的所有开发人员

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9597410/
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:08:37  来源:igfitidea点击:

List all developers on a project in Git

git

提问by Ritam Nemira

Is it possible to list all users that contributed to a project (users that have done commits) in Git?

是否可以在 Git 中列出对项目做出贡献的所有用户(已完成提交的用户)?

Any additional statistics?

有什么额外的统计吗?

回答by Pedro Nascimento

To show all users & emails, and the number of commits in the CURRENT branch:

要显示所有用户和电子邮件,以及 CURRENT 分支中的提交数量:

git shortlog --summary --numbered --email

Or simply:

或者干脆:

git shortlog -sne

To show users from all branches(not only the ones in the current branch) you have to add --allflag:

要显示来自所有分支的用户(不仅是当前分支中的用户),您必须添加--all标志:

git shortlog -sne --all

回答by Guillaume Vincent

If you want to be more specific in the list (find a list of unique committer and author), you could use git log:

如果您想在列表中更具体(查找唯一提交者和作者的列表),您可以使用git log

git log --pretty="%an %ae%n%cn %ce" | sort | uniq
  • %anauthor name
  • %aeauthor email
  • %nnew line
  • %cncommitter name
  • %cecommitter email
  • %an作者姓名
  • %ae作者邮箱
  • %n新队
  • %cn提交者姓名
  • %ce提交者电子邮件

Other placeholders are described in the pretty print documentation of git log.

其他占位符中描述的漂亮打印文档git log

回答by Santa Zhang

You can try this:

你可以试试这个:

git log | grep Author: | sort | uniq

回答by VonC

(users that have done commits)

(已完成提交的用户)

Note: by default git shortloggroups commits by authors.

注意:默认情况下,git shortlog作者分组提交。

If you need to group them by committers, you will need Git 2.12 (Q1 2017)

如果需要按提交者对它们进行分组,则需要 Git 2.12(2017 年第一季度)

git shortlog -snc

See commit 03f4082(16 Dec 2016) by Jeff King (peff).
See commit fbfda15(11 Oct 2016) by Linus Torvalds (torvalds).
(Merged by Junio C Hamano -- gitster--in commit ad1b4e2, 27 Dec 2016)

请参阅Jeff King ( ) 的提交 03f4082(2016 年 12 月 16 日。 请参阅Linus Torvalds ( ) 的commit fbfda15(2016 年 10 月 11 日)(由Junio C Hamano合并-- --提交 ad1b4e2 中,2016 年 12 月 27 日)peff
torvalds
gitster

Linus Torvalds himself introduces this feature:

Linus Torvalds 自己介绍了这个功能:

shortlog: group by committer information

In some situations you may want to group the commits not by author, but by committer instead.

For example, when I just wanted to look up what I'm still missing from linux-nextin the current merge window, I don't care so much about who wrote a patch, as what git treeit came from, which generally boils down to "who committed it".

So make git shortlog take a "-c" or "--committer" option to switch grouping to that.

shortlog: 按提交者信息分组

在某些情况下,您可能希望不按作者,而是按提交者对提交进行分组。

例如,当我只想linux-next在当前的合并窗口中查找我仍然缺少的内容时,我不太关心谁写了补丁,而是git tree它来自什么,这通常归结为“谁提交了它”。

所以让 git shortlog 使用“ -c”或“ --committer”选项来切换分组。

回答by ΦXoc? ? Пepeúpa ツ

Another option can be:

另一种选择可以是:

git log --format='%aN' | sort -u

回答by adem

Great answers by @pedro-nascimento, by @mic_e and others already solve the problem.

@pedro-nascimento、@mic_e 和其他人的出色回答已经解决了问题。

In addition, you can add the following line to your .gitconfig

此外,您可以将以下行添加到您的 .gitconfig

contributors = shortlog -e --summary --numbered

or in shell type

或在外壳类型

git config --global alias.contributors 'shortlog -e --summary --numbered'

And after that you can simply invoke: git contributors

之后,您可以简单地调用: git contributors

回答by Daniel Lee

I haven't got around to testing it myself yet, but this looks really nice for project statistics for a Git repository: https://github.com/visionmedia/git-extras

我还没有自己测试它,但这对于 Git 存储库的项目统计来说看起来非常好:https: //github.com/visionmedia/git-extras

Check out the bincatalog to see the the different scripts.

查看bin目录以查看不同的脚本。

For example, the git-countscript (commit count per committer):

例如,git-count脚本(每个提交者的提交计数):

git shortlog -n $@ | grep "):" | sed 's|:||'

回答by honzakuzel1989

You can try an amazing pack called git-extras. Specifically, the commands git-summary, git-countand maybe some other.

你可以尝试一个叫做git-extras的神奇包。具体来说,命令git-summarygit-count以及其他一些.