How to attribute a single commit to multiple developers?

GitSvnVersion ControlBazaar

Git Problem Overview


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 Solutions


Solution 1 - Git

Commit title

Commit body

Co-authored-by: name <additional-dev-1@example.com>
Co-authored-by: name <additional-dev-2@example.com>

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

Solution 2 - Git

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][2]). This is also [one of the solutions][3] on the [git-core bug][4] linked in [Gerry's answer][5]

Co-authored-by: Some One <some.one@example.foo>

In that comment on May 5, 2010, Josh Triplett also suggests implementing corresponding support in git.

As [Llopis][6] pointed out in a comment, GitHub announced support for this on their blog on Jan 29, 2018: [Commit together with co-authors][7] ([details][8]).

[2]: https://wiki.openstack.org/wiki/GitCommitMessages#Including_external_references "Openstack Git Commit Good Practice" [3]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=451880#12 [4]: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=451880 [5]: https://stackoverflow.com/a/7442255/12039 [6]: https://stackoverflow.com/users/2886003 [7]: https://github.com/blog/2496-commit-together-with-co-authors [8]: https://help.github.com/articles/creating-a-commit-with-multiple-authors/ "GitHub Documentation - Creating a commit with multiple authors"

Solution 3 - Git

For Bazaar:

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

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

Solution 4 - Git

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
user.email[email protected]

for you.

Solution 5 - 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] https://stackoverflow.com/questions/18750808/difference-between-author-and-committer-in-git

Solution 6 - Git

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

E.g.

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

Solution 7 - Git

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

Solution 8 - Git

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

Solution 9 - Git

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser360907View Question on Stackoverflow
Solution 1 - GitGerryView Answer on Stackoverflow
Solution 2 - GitKariemView Answer on Stackoverflow
Solution 3 - GitbialixView Answer on Stackoverflow
Solution 4 - GitCiro Santilli Путлер Капут 六四事View Answer on Stackoverflow
Solution 5 - GitJakub KukulView Answer on Stackoverflow
Solution 6 - GitDennisView Answer on Stackoverflow
Solution 7 - Gitfoo0x29aView Answer on Stackoverflow
Solution 8 - GitAneeshView Answer on Stackoverflow
Solution 9 - GitnsnView Answer on Stackoverflow