git 如何将单个提交归因于多个开发人员?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7442112/
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
How to attribute a single commit to multiple developers?
提问by
The way all version control systems I'm familiar with work is that each commit is attributed to a single developer. The rise of Agile Engineering, and specifically pair programming, has lead to a situation where two developers have made a significant contribution to the same task, a bug fix for example.
我熟悉的所有版本控制系统的工作方式是每次提交都归于一个开发人员。敏捷工程的兴起,特别是结对编程,导致了这样一种情况,即两名开发人员对同一任务做出了重大贡献,例如错误修复。
The issue of attribution won't be too much of a big deal in a work environment since the project manager will be aware of the work the pairs are doing, but what about if two open source contributors decide to pair up and push out some code to a particular project that has no idea they're working together. Is there any way for a version control system like Git to attribute a particular patch to multiple developers?
归因问题在工作环境中不会太重要,因为项目经理会知道这对正在做的工作,但是如果两个开源贡献者决定结对并推出一些代码呢?到一个不知道他们正在合作的特定项目。有没有办法让像 Git 这样的版本控制系统将特定补丁分配给多个开发人员?
采纳答案by Gerry
Commit title
Commit body
Co-authored-by: name <[email protected]>
Co-authored-by: name <[email protected]>
- Supported by Githuband Gitlab
- Used by others: https://git.wiki.kernel.org/index.php/CommitMessageConventions
One problem with this approachis that you can't create a signed key for this group of devs, so you could essentially add anybody to this list even if they didn't work on a feature and Github would treat it as if they did. However, this shouldn't be an issue in most cases.
这种方法的一个问题是您无法为这组开发人员创建签名密钥,因此您基本上可以将任何人添加到此列表中,即使他们没有在某个功能上工作并且 Github 会像他们一样对待它。但是,在大多数情况下,这应该不是问题。
e.g. Co-authored-by: Linus Torvalds <[email protected]>
例如 Co-authored-by: Linus Torvalds <[email protected]>
With normal authors or signing groups (the old method) you would see it's not signed and know that you can't trust the commit. However, there is no signing process on co-authors.
对于普通作者或签名组(旧方法),您会看到它没有签名,并且知道您不能信任提交。但是,共同作者没有签名过程。
Mostly outdated answer:
大多数过时的答案:
One solution would be to set a name for the pair:
一种解决方案是为这对设置一个名称:
git config user.name "Chris Wilson and John Smith"
Here is a related bug report with other temporary solutions:
这是其他临时解决方案的相关错误报告:
Bug git-core: Git should support multiple authors for a commit
回答by Kariem
A git convention is to use Co-Authored-Byat the end of the commit message (git kernel: Commit Message Conventions, referring to Openstack Commit Messages). This is also one of the solutionson the git-core buglinked in Gerry's answer
一个 git 约定是在提交消息的末尾使用Co-Authored-By(git kernel: Commit Message Conventions,指的是Openstack Commit Messages)。这也是Gerry's answer 中链接的git-core 错误的解决方案之一
Co-authored-by: Some One <[email protected]>
In that comment on May 5, 2010, Josh Triplett also suggests implementing corresponding support in git.
在 2010 年 5 月 5 日的评论中,Josh Triplett 还建议在 git 中实现相应的支持。
As Llopispointed out in a comment, GitHub announced support for this on their blog on Jan 29, 2018: Commit together with co-authors(details).
正如Llopis在评论中指出的那样,GitHub 于 2018 年 1 月 29 日在他们的博客上宣布了对此的支持:Commit with co-authors( details)。
回答by bialix
For Bazaar:
对于集市:
bzr commit --author Joe --author Alice --author Bob
Those names will be shown in the log separately from committer name.
这些名称将与提交者名称分开显示在日志中。
回答by Jakub Kukul
git distinguishes between a commit's author
and committer
[1]. You could use it as a work-around, e.g. sign yourself as the committer
and your co-author as the author
:
git 区分提交author
和committer
[1]。您可以将其用作解决方法,例如将自己签名为 ,将committer
您的合著者签名为author
:
GIT_COMMITTER_NAME='a' GIT_COMMITTER_EMAIL='a@a' git commit --author 'b <b@b>'
This way, both you and your co-author will be recorded in the git history. Running git log --format=fuller
, will give you something like:
这样,您和您的合著者都将被记录在 git 历史记录中。运行git log --format=fuller
,会给你类似的东西:
commit 22ef837878854ca2ecda72428834fcbcad6043a2
Author: b <b@b>
AuthorDate: Tue Apr 12 06:53:41 2016 +0100
Commit: a <a@a>
CommitDate: Tue Apr 12 09:18:53 2016 +0000
Test commit.
[1] Difference between author and committer in Git?
[1] Git 中作者和提交者的区别?
回答by foo0x29a
Alternatively, there is an open source project, which I am a contributor, on GitHub that provides a good way to do it from the command line. This project helps you to set an alias in order to create co-autored commits as follows:
或者,GitHub 上有一个开源项目,我是该项目的贡献者,它提供了一种从命令行执行此操作的好方法。该项目可帮助您设置别名以创建共同自动提交,如下所示:
$ git co-commit -m "Commit message" --co "co-author <co-author-email>"
$ git co-commit -m "Commit message" --co "co-author <co-author-email>"
Using this approach, you are able to create co-authored commits without a graphical interface.
使用这种方法,您可以在没有图形界面的情况下创建共同创作的提交。
回答by Dennis
Try git-mob, we built it for attributing co-authors on commits.
试试 git-mob,我们构建它是为了在提交时归因于共同作者。
E.g.
例如
git mob <initials of co-authors>
git commit
git solo
回答by Aneesh
We add our names to each commit message at the end as a convention
eg : Implemented cool feature <Aneesh | Hiren>
我们将我们的名字作为约定添加到每个提交消息的末尾,例如: Implemented cool feature <Aneesh | Hiren>
回答by nsn
Most of the co-author tools do not support autocompletion. You can try git-coco, its written in python3 (I'm the developer). git-coco
supports autocomplete and auto-suggest.
Here is a snapshot
autocomplete on sample authors
大多数共同创作工具不支持自动完成。您可以尝试git-coco,它是用 python3 编写的(我是开发人员)。git-coco
支持自动完成和自动建议。这是示例作者的快照
自动完成