What is the difference between a committer and an author?

Updated at:

This topic explains the committer and author roles in Git.

Set commit information

Git is a distributed versioning system. You can use the following commands to set your name and email address:

git config --global user.name "Your Name"
git config --global user.email your.name@example.com

Git commits with two attributions

If you view a commit using the detailed format (--pretty=fuller), you will see two attributions: an author and a committer. For example, the metadata for the commit associated with the v2.45.0 tag in the Git project shows the author (Author), author date (AuthorDate), committer (Commit), and commit date (CommitDate).

$ git log -1 --pretty=fuller v2.45.0
commit 786a3e4b8d754d2b14b1208b98eeb0a554ef19a8 (tag: v2.45.0, github/maint)
Author:     Junio C Hamano <gitgits***@pobox.com>
AuthorDate: 2024-04-29 07:30:29 -0700
Commit:     Junio C Hamano <gitgits***@pobox.com>
CommitDate: 2024-04-29 07:30:29 -0700

    Git 2.45
    
    Signed-off-by: Junio C Hamano <gits***@pobox.com>

This is because of the mailing list workflow that Git founder Linus Torvalds uses for the Git and Linux projects:

  • A developer converts a commit into a patch file and sends it to the mailing list as an email.

  • Developers conduct a code review on the mailing list.

  • After multiple iterations and a successful review, the project maintainer applies the email patch as a commit to the Git repository.

  • The original author remains the same after the conversion. The committer is the project maintainer who applied the patch as a commit.

For example, the author and committer are different in the following commit because of the mailing list workflow used in the Git project.

$ git log -1 --pretty=fuller "tags/v2.44.0-rc0~35^2~5"
commit 4a61faf75d684eb31c23521bc0e3c3cac5fd1553
Author:     Jiang Xin <zhzhiyou***@alibaba.com>
AuthorDate: 2024-01-21 21:15:33 +0800
Commit:     Junio C Hamano <gitsgits***@pobox.com>
CommitDate: 2024-01-22 07:54:37 -0800

    transport-helper: no connection restriction in connect_helper
    
    ...
    
    Helped-by: Junio C Hamano <gitster@pgits***@pobox.com>
    Helped-by: Linus Arver <linusa@googllin***@google.com>
    Signed-off-by: Jiang Xin <zhiyou.jxzhiyou***@alibaba-inc.com>
    Signed-off-by: Junio C Hamano <gits***@pobox.com>

A commit can involve multiple developers. Signature information, such as Helped-by and Signed-off-by, can be added to the end of the commit message.

The two attributions include two timestamps: the author date and the commit date. This makes the two attributions useful even when the author and the committer are the same person. For example, consider this commit from the Git localization project:

$ git log --pretty=fuller -1 "v2.44.0-rc2~2^2~10"
commit 1bb7fcbffc213db044476998f3a14b2597f3c540
Author:     Jiang Xin <woworldhello.***@gmail.com>
AuthorDate: 2024-02-16 11:20:39 +0800
Commit:     Jiang Xin <worworldhello.***@gmail.com>
CommitDate: 2024-02-16 11:51:19 +0800

    l10n: ci: disable cache for setup-go to suppress warnings
    
    After we upgraded actions/setup-go to v5, the following warning message
    was reported every time we ran the CI.
    
        Restore cache failed: Dependencies file is not found ...
    
    Disable cache to suppress warning messages as described in the solution
    below.
    
        https://github.com/actions/setup-go/issues/427
    
    Signed-off-by: Jiang Xin <worldhello.***@gmail.com>

In this example, the two timestamps are half an hour apart. After making the initial commit, the author improved the commit message by running the following command:

$ git commit -s --amend

Validate the author and committer

Some companies require restrictions on the committer's email address. Apsara Devops provides this feature. If a committer's email address does not comply with the rules, the push operation fails and returns an error. For more information, see Push rule settings.

First, check that your username and email are set correctly. You can use the git config user.name and git config user.email commands to view the current settings. If the settings are incorrect, you can use the commands mentioned previously to update them.

To change the committer's email for the most recent commit, you can use the following command:

git commit --amend

If the author's email also needs to be changed, you can add the --reset-author parameter and use the following command:

git commit --reset-author --amend

To modify historical commits, you can use the interactive rebase command: git rebase -i. You can stop at the commit you want to modify and then use the preceding commands to change the committer and author attributions. For more information about git rebase operations, see the relevant documentation.