How do I change the author of my commit after I've already pushed it to the upstream repository
If the message to be changed is for the latest commit to the repository, then the following commands are to be executed: git commit --amend -m "New message" git push --force repository-name branch-name.
Using Rebase This will change both the committer and the author to your user.name / user. email configuration. If you did not want to change that config, you can use --author "New Author Name <[email protected]>" instead of --reset-author . Note that doing so will not update the committer -- just the author.
The commit you want to change is now represented in the first line. To change its author, you want to change the verb in front of it, from pick into edit . As you have just changed the author, there will be no conflicts and your rebase will finish successfully.
You will have to amend the commit ( git commit --amend --author="New Author Name <[email protected]>"
) on your local repository and force push- git push -f
the change ( rewriting history is generally a bad practice once you have pushed upstream ).
In case you got multiple git-push done without realizing that the commits went with a different email account. now you need to change that. here is the command I have used to transform all my previous commit with a different email to the new email id.
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='yourname'; GIT_AUTHOR_EMAIL='[email protected]'; GIT_COMMITTER_NAME='yourname'; GIT_COMMITTER_EMAIL='[email protected]';" HEAD;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With