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.

Make your mark

Join the writer's program

Are you a developer and love writing and sharing your knowledge with the world? Join our guest writing program and get paid for writing amazing technical guides. We'll get them to the right readers that will appreciate them.

Write for us
Writer of the month
Marin Bezhanov
Marin is a software engineer and architect with a broad range of experience working...
Build on top of Better Stack

Write a script, app or project on top of Better Stack and share it with the world. Make a public repository and share it with us at our email.

community@betterstack.com

or submit a pull request and help us build better products for everyone.

See the full list of amazing projects on github