What is the difference between author and committer in Git?

I just came across the following commit on GitHub: https://github.com/felixge/node-formidable/commit/0a0b150668daa3c6f01626d2565b898e5da12392

How does one go about having multiple authors on the same commit like that?


That's not really two authors - that's an author and a committer. The two fields have different meanings. The author is the one who created the content, and the committer is the one who committed it. When you do a normal commit, you are both. (And both come with an associated email and timestamp.)

But they can become different in a few key ways:

  • git format-patch / git am - this pair lets you turn commits into patches, generally submitted by email, then have someone else apply them. You remain the author; the person who applies them is the committer. This is pretty definitely what happened on github there.

  • git commit --amend, git rebase, git filter-branch - These are all basically variants on history rewriting, ranging from single commit to some history of a branch to the entire history. They can potentially modify the committer information - in particular, they always rewrite the committer timestamp. The original author remains in place (in default modes of operation), and if the author is also the one doing the rewriting, their name and email stay, but the timestamp is naturally different.


There aren't multiple authors associated with that commit (nor is it currently possible to assign multiple authors to a single commit). In this case, gliese1337 was the author, and felixge was the committer. Most likely, this occurred because gliese1337 submitted a pull request which was accepted and then committed by felixhe (the repository owner). That workflow's pretty common on GitHub. This is also helpful for instances when a project maintainer receives a patch via email, so the author of the patch itself still receives credit for the patch, even if he or she doesn't have commit access to the project.

A couple of related links:

Short Git Wiki section on author attribution
A feature request for multiple author functionality in Git core


It is not multiple authors. One is the author and another is commiter.

If you'd make a clone you could see it clearly:

$ git cat-file -p 0a0b150668daa3c6f016
tree 91edcb411b7cd0708c1f5bb05621846146c9425a
parent 6b9ffe3653fe59f035b01ba1f46b5f2650be00ca
author Logan Kearsley <[email protected]> 1308937685 -0700
committer Felix Geisendo╠Иrfer <[email protected]> 1309117893 +0200

Slight but definite & consistent performance boost.

Git web interface like GitHub and GitLab

In such systems, when merging a patch the author may or may not be different from the committer depending on the repo settings.

Since Git(Hub|Lab) hold both the upstream and the fork repositories on a the same machine, it can do automatically do anything that you can do locally as well:

  • Create a merge commit.

    Does not generate author != committer.

    Keeps the SHA or the new commit intact, and creates a new commit:

    * Merge commit (committer == author == project maintainer)
    |\
    | * Feature commit (committer == author == contributor)
    |/
    * Old master (random committer and author)
    

    Historically, this was the first available method on GitHub.

    Locally, this is done with git merge --no-ff.

    This produces two commits per pull request, and keeps a fork in the git history.

  • rebase on top of master

    While this is not mandatory in principle, and not even done by default locally by git rebase, GitHub also hacks the commits to set committer == whoever pressed the merge button.

    The reason for doing this, is that it gives accountability to the project maintainer.

    The git tree now looks like:

    * Feature commit (committer == maintainer, author == contributor)
    |
    * Old master (random committer and author)    
    

    which is exactly like that of the git apply email patches.

On GitHub currently:

  • you choose the method when merging via the dropdown on the merge button
  • methods can be enabled or disabled on the repo settings by the owner

https://help.github.com/articles/about-merge-methods-on-github/