How Can I Change the Commit Author for a Single Commit?

Better Stack Team
Updated on June 24, 2024

To change the commit author for a single commit in Git, you can use the git commit --amend command followed by the --author option. Here's how you can do it:

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

Replace "New Author Name <new.email@example.com>" with the new author name and email you want to assign to the commit.

For example, if you want to change the author of the last commit, you would run:

 
git commit --amend --author="John Doe <john.doe@example.com>"

Note:

  • When using git commit --amend to change the commit author, Git will open your default text editor to allow you to modify the commit message as well. You can save and close the editor without making any changes if you only want to modify the author.
  • If you're changing the author of a commit that has already been pushed to a remote repository, you'll need to force-push the amended commit to update the remote history. This can cause issues for collaborators, so use it with caution.
  • Changing commit authors is typically only necessary for fixing mistakes or updating outdated information. It's important to communicate any changes to other collaborators, especially if they have already based their work on the original commits.
Got an article suggestion? Let us know
Explore more
Git
Licensed under CC-BY-NC-SA

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.