如何将单个提交归因于多个开发人员?
我熟悉的所有版本控制系统的工作方式都是每次提交都归属于单个开发人员。敏捷工程,特别是结对编程的兴起,导致了这样一种情况:两名开发人员对同一任务(例如错误修复)做出了重大贡献。
在工作环境中,归因问题不会太大,因为项目经理会知道两人正在做的工作,但是如果两个开源贡献者决定结对并推出一些代码怎么办到一个不知道他们正在一起工作的特定项目。像 Git 这样的版本控制系统有什么方法可以将特定补丁分配给多个开发人员吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
这种方法的一个问题是,您无法为这组开发人员创建签名密钥,因此您实际上可以将任何人添加到此列表中,即使他们不处理某个功能并且 GitHub 会处理它就像他们那样。但是,在大多数情况下这不应该是问题。
例如
共同创作者:Linus Torvalds [电子邮件受保护]>
对于普通作者或签名组(旧方法),您会看到它未签名,并且知道您不能信任该提交。然而,没有共同作者的签名过程。
大多数过时的答案:
一种解决方案是为该对设置一个名称:
这是与其他临时解决方案相关的错误报告:
Bug git-core:Git 应支持多个作者提交
One problem with this approach is 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.
e.g.
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:
Here is a related bug report with other temporary solutions:
Bug git-core: Git should support multiple authors for a commit
git 约定是在提交消息末尾使用Co-authored-by(git 内核:提交消息约定,参考 Openstack 提交消息)。这也是 解决方案之一 href="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=451880" rel="noreferrer">git-core bug 链接于 Gerry 的回答
在 2010 年 5 月 5 日的评论中,Josh Triplett 还建议在 git 中实现相应的支持。
正如 Llopis 在评论中指出的那样,GitHub 于 2018 年 1 月 29 日在其博客上宣布支持此功能:与共同作者一起提交 (详细信息)。
A git convention is to use Co-authored-by at the end of the commit message (git kernel: Commit Message Conventions, referring to Openstack Commit Messages). This is also one of the solutions on the git-core bug linked in Gerry's answer
In that comment on May 5, 2010, Josh Triplett also suggests implementing corresponding support in git.
As Llopis pointed out in a comment, GitHub announced support for this on their blog on Jan 29, 2018: Commit together with co-authors (details).
对于 Bazaar:
这些名称将与提交者名称分开显示在日志中。
For Bazaar:
Those names will be shown in the log separately from committer name.
git-pair
https://github.com/pivotal/git_scripts# git-pair
这个来自 Pivotal 的简单脚本用于自动化 Git 结对编程归因。
您创建一个
.pairs
文件,例如:然后:
创建:sets :。
为您
git-pair
https://github.com/pivotal/git_scripts#git-pair
This simple script from Pivotal to automate Git pair programming attribution.
You create a
.pairs
file like:and then:
sets:
for you.
git 区分提交的
作者
和提交者
[1]。您可以将其用作解决方法,例如将自己标记为提交者
,将您的共同作者标记为作者
:这样,您和您的共同作者都将记录在 git 历史记录中。运行 git log --format=fuller ,会给你类似的东西:
[1] Git 中作者和提交者之间的区别?
git distinguishes between a commit's
author
andcommitter
[1]. You could use it as a work-around, e.g. sign yourself as thecommitter
and your co-author as theauthor
: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:[1] Difference between author and committer in Git?
或者,GitHub 上有一个我参与的开源项目这提供了一种从命令行执行此操作的好方法。该项目可帮助您设置别名以创建共同创作的提交,如下所示:
$ git co-commit -m "Commit message" --co "co-author"< /code>
使用这种方法,您可以在没有图形界面的情况下创建共同创作的提交。
Alternatively, there is an open source project, which I contribute to, 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-authored commits as follows:
$ 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.
尝试 git-mob,我们构建它是为了在提交时归属共同作者。
例如
Try git-mob, we built it for attributing co-authors on commits.
E.g.
作为惯例,我们将我们的名字添加到每个提交消息的末尾
例如:
实现了很酷的功能
We add our names to each commit message at the end as a convention
eg :
Implemented cool feature <Aneesh | Hiren>
大多数共同作者工具不支持自动完成。你可以尝试 git-coco,它是用 python3 编写的(我是开发人员)。
git-coco
支持自动完成和自动建议。这是一个快照
自动完成示例作者
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
Apache Subversion 表示补丁作者[1] 应该是
补丁作者:
。您可以提供多个作者。me
是一个特殊值,表示提交者本身。注释
到 Subversion 存储库)需要将补丁发送到 Subversion
邮件列表。然后其中一位提交者可以提交补丁。在
提交者和补丁作者可以不同。 (就像在
Git 但 Git 具有单一作者元数据(缺乏能力
对于多个作者,因此这个主题(部分)))
Apache Subversion says that patch authors [1] should be
credited with
Patch by: <author>
. You can provide multiple authors.me
is a special value meaning the commiter themselves.Notes
to the Subversion repository) need to send patches to the Subversion
mailing list. Then one of the committers can commit the patch. In
turn the committer and patch author can be different. (Just like in
Git but Git has the single Author metadata (lacking the capability
for multiple authors, hence this topic (in part)))