Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@trey
Last active January 3, 2024 16:53
Show Gist options
  • Star 51 You must be signed in to star a gist
  • Fork 12 You must be signed in to fork a gist
  • Save trey/9588090 to your computer and use it in GitHub Desktop.
Save trey/9588090 to your computer and use it in GitHub Desktop.
Change the email address for a git commit.

Change the email address for a git commit.

$ git commit --amend --author="Author Name <email@address.com>"

or

$ git commit --amend --reset-author

If you need to change the author for a commit older than the most recent, do a git rebase -i. For example, if you wanted to change the penultimate commit, you'd run:

$ git rebase -i HEAD~2

Then choose e or edit next to the appopriate commit, then when it asks you to amend, run the same command as you would for the most recent commit:

$ git commit --amend --reset-author

Then, to finish, you'd run:

$ git rebase --continue

And you're done. Don't forget you'll have to --force push if you've already pushed those commits to your remote.

source

@trey
Copy link
Author

trey commented Mar 16, 2014

This is a Solutions Log post.

@EldorjonJuraev
Copy link

Thank you so much! Just what I was looking for 💯

@jcnars
Copy link

jcnars commented May 19, 2021

This saved me with my commit that had the incorrect email address without jeopardizing the existing comments on an already in-review PR!
Thanks much

@trey
Copy link
Author

trey commented May 19, 2021

@jcnars, happy it helped!

@treymack-wk
Copy link

git commit --amend --reset-author --no-edit is cool to skip the editor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment