Changing git commit's author or email
Imagine you are pair programming, but didn't remember to change the email & names before committing.
Or you want to choose another email (personal vs professional, etc)
As that may rewrite history, be careful if you have published the commits to another repo (eg, git push)
Stackoverflow solution -> pointing to github script.
Copied here for archival:
#!/bin/sh
git filter-branch --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [ "$GIT_COMMITTER_EMAIL" = "your@email.to.match" ]
then
cn="Your New Committer Name"
cm="Your New Committer Email"
fi
if [ "$GIT_AUTHOR_EMAIL" = "your@email.to.match" ]
then
an="Your New Author Name"
am="Your New Author Email"
fi
export GIT_AUTHOR_NAME="$an"
export GIT_AUTHOR_EMAIL="$am"
export GIT_COMMITTER_NAME="$cn"
export GIT_COMMITTER_EMAIL="$cm"
'
Written by Alvaro Garcia
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Pair programming
Authors
roylines
2.017K
lynnlangit
1.152K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#