user1050797
user1050797

Reputation: 261

Changing git authorship after git push

How do I change the author of my commit after I've already pushed it to the upstream repository

Upvotes: 24

Views: 16044

Answers (2)

Tarandeep Singh
Tarandeep Singh

Reputation: 1390

Another complete solution.

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;

Upvotes: 16

manojlds
manojlds

Reputation: 301177

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 ).

Upvotes: 29

Related Questions