Difference between author and committer in Git?

mu 無 picture mu 無 · Sep 11, 2013 · Viewed 84.3k times · Source

I am trying to make a commit like

git commit --author="John Doe <[email protected]>" -m "<the usual commit message>"

where John Doe is some user in whose name I want to make the commit.

It appears all right in git log. However, when I do a gitk, the author name is correct, but the committer name is picked from my global git config settings (and is thus set to my name/email).

Questions

  1. What is the difference between the two (committer vs author)?

  2. Should I be setting the committer as well to the other user?

  3. If yes, how?

Answer

user456814 picture user456814 · Sep 12, 2013

The original poster asks:

What is the difference between the two (Committer vs author)?

The author is the person who originally wrote the code. The committer, on the other hand, is assumed to be the person who committed the code on behalf of the original author. This is important in Git because Git allows you to rewrite history, or apply patches on behalf of another person. The FREE online Pro Git book explains it like this:

You may be wondering what the difference is between author and committer. The author is the person who originally wrote the patch, whereas the committer is the person who last applied the patch. So, if you send in a patch to a project and one of the core members applies the patch, both of you get credit — you as the author and the core member as the committer.

The original poster asks:

Should I be setting the committer as well to the other user?

No, if you want to be honest, you should not be setting the committer to the author, unless the author and the committer are indeed the same person.