How to change the author of a Git commit

Greg Foster
Greg Foster
Graphite software engineer

In Git, each commit is associated with an author and a committer. Sometimes, it may be necessary to change the author details of a commit—perhaps due to a misconfiguration of user details or when migrating commit histories between projects. This guide will walk you through the process of changing the author of a Git commit, covering various scenarios from a single commit amendment to changing the authorship of multiple commits across a project’s history.

Before diving into the procedures, it’s important to distinguish between an "author" and a "committer":

  • Author: The person who originally wrote the code.
  • Committer: The person who last applied the code to the repository, which could be different in cases of patches or collaborative projects.

If you've realized that your commit authorship details are incorrect across many projects, you might want to update your global Git configuration:

Terminal
git config --global user.name "New Author Name"
git config --global user.email "new.author@example.com"

This example changes the author config at the "global" level, but Git offers several levels of configuration settings, each catering to different scopes: system, global, and local.

The system level affects all users on a machine and all their repositories; settings are typically stored in a configuration file accessible system-wide, such as /etc/gitconfig.

The global level applies to every repository the current user works with on the machine, with settings usually found in the user’s home directory, for example, ~/.gitconfig or ~/.config/git/config.

The local level is specific to a particular repository and overrides system and global settings; these configurations are stored in .git/config within the repository itself.

The author can be set separately at each level with order of precedence: local, global, then system.

To change the author information for the most recent commit run:

Terminal
git commit --amend --author="New Author Name <new.author@example.com>"

This command opens your default text editor to edit the commit message, and it replaces the author details with the new ones specified.

If the commit has already been pushed to a remote repository (like GitHub) and needs to be corrected, perform the amendment locally as shown above, and then force-push the changes:

Terminal
git push --force

Note: Force-pushing can disrupt the history for other collaborators. It should be used with caution, particularly in shared repositories.

To change the author of a specific commit that isn't the most recent, you'll need to use an interactive rebase:

  1. Start an interactive rebase up to the commit you want to change:

    Terminal
    git rebase -i <commit-id>^

    Replace <commit-id> with the hash of the commit just before the one you want to amend.

  2. In the text editor that opens, change the word pick to edit next to the commit you want to amend, then save and close the editor.

  3. Amend the commit:

    Terminal
    git commit --amend --author="New Author Name <new.author@example.com>"
  4. Continue the rebase:

    Terminal
    git rebase --continue

For further reading on commit authors see the official Git documentation.

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2