如何将单个提交归因于多个开发人员?

发布于 2024-12-04 15:36:41 字数 220 浏览 0 评论 0原文

我熟悉的所有版本控制系统的工作方式都是每次提交都归属于单个开发人员。敏捷工程,特别是结对编程的兴起,导致了这样一种情况:两名开发人员对同一任务(例如错误修复)做出了重大贡献。

在工作环境中,归因问题不会太大,因为项目经理会知道两人正在做的工作,但是如果两个开源贡献者决定结对并推出一些代码怎么办到一个不知道他们正在一起工作的特定项目。像 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(10

香草可樂 2024-12-11 15:36:41
Commit title

Commit body

Co-authored-by: name <[email protected]>
Co-authored-by: name <[email protected]>

这种方法的一个问题是,您无法为这组开发人员创建签名密钥,因此您实际上可以将任何人添加到此列表中,即使他们不处理某个功能并且 GitHub 会处理它就像他们那样。但是,在大多数情况下这不应该是问题。

例如 共同创作者:Linus Torvalds [电子邮件受保护]>

对于普通作者或签名组(旧方法),您会看到它未签名,并且知道您不能信任该提交。然而,没有共同作者的签名过程。


大多数过时的答案:

一种解决方案是为该对设置一个名称:

git config user.name "Chris Wilson and John Smith"

这是与其他临时解决方案相关的错误报告:

Bug git-core:Git 应支持多个作者提交

Commit title

Commit body

Co-authored-by: name <[email protected]>
Co-authored-by: name <[email protected]>

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:

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

寒尘 2024-12-11 15:36:41

git 约定是在提交消息末尾使用Co-authored-bygit 内核:提交消息约定,参考 Openstack 提交消息)。这也是 解决方案之一 href="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=451880" rel="noreferrer">git-core bug 链接于 Gerry 的回答

Co-authored-by: Some One <[email protected]>

在 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

Co-authored-by: Some One <[email protected]>

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).

如此安好 2024-12-11 15:36:41

对于 Bazaar:

bzr commit --author Joe --author Alice --author Bob

这些名称将与提交者名称分开显示在日志中。

For Bazaar:

bzr commit --author Joe --author Alice --author Bob

Those names will be shown in the log separately from committer name.

゛时过境迁 2024-12-11 15:36:41

git-pair

https://github.com/pivotal/git_scripts# git-pair

这个来自 Pivotal 的简单脚本用于自动化 Git 结对编程归因。

您创建一个 .pairs 文件,例如:

# .pairs - configuration for 'git pair'
pairs:
  # <initials>: <Firstname> <Lastname>[; <email-id>]
  eh: Edward Hieatt
  js: Josh Susser; jsusser
  sf: Serguei Filimonov; serguei
email:
  prefix: pair
  domain: pivotallabs.com
  # no_solo_prefix: true
#global: true

然后:

git pair sp js

创建:sets :。

user.name=Josh Susser & Sam Pierson
[email protected]

为您

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:

# .pairs - configuration for 'git pair'
pairs:
  # <initials>: <Firstname> <Lastname>[; <email-id>]
  eh: Edward Hieatt
  js: Josh Susser; jsusser
  sf: Serguei Filimonov; serguei
email:
  prefix: pair
  domain: pivotallabs.com
  # no_solo_prefix: true
#global: true

and then:

git pair sp js

sets:

user.name=Josh Susser & Sam Pierson
[email protected]

for you.

绝影如岚 2024-12-11 15:36:41

git 区分提交的作者提交者 [1]。您可以将其用作解决方法,例如将自己标记为提交者,将您的共同作者标记为作者

GIT_COMMITTER_NAME='a' GIT_COMMITTER_EMAIL='a@a' git commit --author 'b <b@b>'

这样,您和您的共同作者都将记录在 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] Git 中作者和提交者之间的区别?

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_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:

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?

淡莣 2024-12-11 15:36:41

或者,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.

爱你不解释 2024-12-11 15:36:41

尝试 git-mob,我们构建它是为了在提交时归属共同作者。

例如

git mob <initials of co-authors>
git commit
git solo

Try git-mob, we built it for attributing co-authors on commits.

E.g.

git mob <initials of co-authors>
git commit
git solo
書生途 2024-12-11 15:36:41

作为惯例,我们将我们的名字添加到每个提交消息的末尾
例如:实现了很酷的功能

We add our names to each commit message at the end as a convention
eg : Implemented cool feature <Aneesh | Hiren>

面如桃花 2024-12-11 15:36:41

大多数共同作者工具不支持自动完成。你可以尝试 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

我乃一代侩神 2024-12-11 15:36:41

Apache Subversion 表示补丁作者[1] 应该是
补丁作者:。您可以提供多个作者。

提交其他人编写的补丁时,请使用“Patch by:”
指示作者的行首:[...]

修复问题 #1729:不要因为文件丢失而崩溃。

 * 颠覆/libsvn_ra_ansible/get_editor.c
   (frobnicate_file):在 frobnicate 之前检查文件是否存在。

 补丁作者:J. Random [电子邮件受保护]>
           Enrico Caruso [电子邮件受保护]>
           jcommitter
           我

me 是一个特殊值,表示提交者本身。

注释

  1. 来自非提交者(没有提交访问权限的人)的更改
    到 Subversion 存储库)需要将补丁发送到 Subversion
    邮件列表。然后其中一位提交者可以提交补丁。在
    提交者和补丁作者可以不同。 (就像在
    Git 但 Git 具有单一作者元数据(缺乏能力
    对于多个作者,因此这个主题(部分)))

Apache Subversion says that patch authors [1] should be
credited with Patch by: <author>. You can provide multiple authors.

When committing a patch written by someone else, use "Patch by: " at
the beginning of a line to indicate the author:[…]

Fix issue #1729: Don't crash because of a missing file.

 * subversion/libsvn_ra_ansible/get_editor.c
   (frobnicate_file): Check that file exists before frobnicating.

 Patch by: J. Random <[email protected]>
           Enrico Caruso <[email protected]>
           jcommitter
           me

me is a special value meaning the commiter themselves.

Notes

  1. Changes from non-committers (people who do not have commit access
    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)))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文