How to attribute a single commit to multiple developers?

后端 未结 9 1357
感情败类
感情败类 2020-12-02 06:50

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 pro

相关标签:
9条回答
  • 2020-12-02 07:30

    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?

    0 讨论(0)
  • 2020-12-02 07:32

    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.

    0 讨论(0)
  • 2020-12-02 07:35

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

    0 讨论(0)
  • 2020-12-02 07:39

    For Bazaar:

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

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

    0 讨论(0)
  • 2020-12-02 07:48

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

    E.g.

    git mob <initials of co-authors>
    git commit
    git solo
    
    0 讨论(0)
  • 2020-12-02 07:49
    Commit title
    
    Commit body
    
    Co-authored-by: name <additional-dev-1@example.com>
    Co-authored-by: name <additional-dev-2@example.com>
    
    • Supported by GitHub and GitLab
    • Used by others: https://git.wiki.kernel.org/index.php/CommitMessageConventions

    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 <torvalds@linux-foundation.org>

    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

    0 讨论(0)
提交回复
热议问题