Git — Change commit author name/email

These commands are tested with git version 2.7.4.

GIT rebase command can be used to change git author name & email address but be careful that it will change commit id so if someone else is using it it will create problem.

git rebase -i -p < commit id of the one commit before your bad commits>

Here

-i is for Interactive mode as we want to deal each commit 
-p is to maintain the git tree otherwise git will flatten the git history and you won't be able to identify the point where git merge is carried out.

Change first column of the all the commit ids exposed via rebase to have “edit” command. Once you have typed edit to all required commits, exit from editor and issue

git rebase --continue

As you are only interested to change author name/email, you can use

git commit --amend --author "Correct Author <author@author.com>" --no-edit

Keep on issuing these commands alternatively until git rebase is not finished. Once it is done you will find new author name/email.

In case you are interested to push these new commands, use following: Be careful as we are deleting remote branch.

git push origin --delete branch-name
git push origin branch-name

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s