Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing git authorship after git push

Tags:

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

like image 624
user1050797 Avatar asked Dec 12 '11 20:12

user1050797


People also ask

Can you git amend after push?

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.

How do I change the author of a git repository?

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.

Can you change commit 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.


2 Answers

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

like image 177
manojlds Avatar answered Nov 17 '22 01:11

manojlds


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;
like image 31
Tarandeep Singh Avatar answered Nov 16 '22 23:11

Tarandeep Singh