How to attribute a single commit to multiple devel

2019-01-16 13:22发布

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?

8条回答
欢心
2楼-- · 2019-01-16 13:59

I think that git lacks such a feature. However, git distinguishes between a commit's author and committer [1]. You can 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?

查看更多
Ridiculous、
3楼-- · 2019-01-16 14:00

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=pair+jsusser+sam@pivotallabs.com

for you.

查看更多
Anthone
4楼-- · 2019-01-16 14:00

Alternatively, there is an open source project 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.

查看更多
够拽才男人
5楼-- · 2019-01-16 14:11

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

E.g.

git mob <initials of co-authors>
git commit
git solo
查看更多
做个烂人
6楼-- · 2019-01-16 14:12

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

查看更多
孤傲高冷的网名
7楼-- · 2019-01-16 14:17

For Bazaar:

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

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

查看更多
登录 后发表回答