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

93 svn git version-control bazaar

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

归因问题在工作环境中不会有太大的影响,因为项目经理会知道这对工作正在做的工作,但是如果两个开源贡献者决定配对并推出一些代码呢?对于一个不知道他们在一起工作的特定项目.有没有办法像Git这样的版本控制系统将特定补丁归因于多个开发人员?

Kar*_*iem 62

git约定是在提交消息的末尾使用Co-Authored-By(git kernel:Commit Message Conventions,指的是Openstack Commit Messages).这也是Gerry答案中关联的git-core bug 的解决方案之一

Co-authored-by: Some One <some.one@example.foo>
Run Code Online (Sandbox Code Playgroud)

在2010年5月5日的评论中,Josh Triplett还建议在git中实现相应的支持.

正如Llopis在评论中指出的那样,GitHub在2018年1月29日的博客上宣布了对此的支持:与共同作者一起(详情).

  • 现在由GitHub [支持](https://help.github.com/articles/creating-a-commit-with-multiple-authors/). (7认同)

Ger*_*rry 44

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

Commit title

Commit body

Co-authored-by: name <additional-dev-1@example.com>
Co-authored-by: name <additional-dev-2@example.com>
Run Code Online (Sandbox Code Playgroud)

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

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

  • 如果您不知道此人的电子邮件地址怎么办?有什么方法可以链接 GitHub 用户名等吗? (3认同)
  • 这似乎已经在GitLab中起作用了(请参阅https://gitlab.com/gitlab-org/gitlab-foss/merge_requests/17919) (2认同)

bia*_*lix 26

对于Bazaar:

bzr commit --author Joe --author Alice --author Bob
Run Code Online (Sandbox Code Playgroud)

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


Cir*_*四事件 19

GIT-对

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
Run Code Online (Sandbox Code Playgroud)

然后:

git pair sp js
Run Code Online (Sandbox Code Playgroud)

集:

user.name=Josh Susser & Sam Pierson
user.email=pair+jsusser+sam@pivotallabs.com
Run Code Online (Sandbox Code Playgroud)

为了你.


Jak*_*kul 13

我认为git缺乏这样的功能.但是,git区分了commit authorcommitter[1].您可以将其用作解决方案,例如将自己标记为committer以及您的共同作者author:

GIT_COMMITTER_NAME='a' GIT_COMMITTER_EMAIL='a@a' git commit --author 'b <b@b>'
Run Code Online (Sandbox Code Playgroud)

这样,您和您的共同作者都将被记录在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.
Run Code Online (Sandbox Code Playgroud)

[1] Git中作者和提交者之间的区别?


Den*_*nis 5

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

例如

git mob <initials of co-authors>
git commit
git solo
Run Code Online (Sandbox Code Playgroud)


Thi*_*shi 5

或者,GitHub 上有一个我参与的开源项目,它提供了一种从命令行执行此操作的好方法。该项目可帮助您设置别名以创建共同自动提交,如下所示:

$ git co-commit -m "Commit message" --co "co-author <co-author-email>"

使用这种方法,您可以在没有图形界面的情况下创建共同创作的提交。

  • 据我所知,这是一个 git 别名,它在提交消息的末尾添加了“共同作者:”加上“共同作者 &lt;co-author-email&gt;”。 (8认同)