Skip to content

Instantly share code, notes, and snippets.

@rjshrjndrn
Forked from acdha/rename-authors.sh
Last active December 16, 2021 11:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rjshrjndrn/924b096c1c22f5c8afdd897ca0f14606 to your computer and use it in GitHub Desktop.
Save rjshrjndrn/924b096c1c22f5c8afdd897ca0f14606 to your computer and use it in GitHub Desktop.
Renaming author history in git
#!/bin/sh
# Change the author name/email
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --env-filter '
export GIT_AUTHOR_NAME GIT_AUTHOR_EMAIL GIT_COMMITTER_NAME GIT_COMMITTER_EMAIL;
GIT_AUTHOR_NAME=`echo $GIT_AUTHOR_NAME | sed -e "s/Rajesh Rajendran/rjshrjndrn/g"`;
GIT_AUTHOR_EMAIL=`echo $GIT_AUTHOR_EMAIL | sed -e "s/rjshrjndrn@.*/rjshrjndrn@github.com/g"`;
GIT_COMMITTER_NAME=`echo $GIT_COMMITTER_NAME | sed -e "s/Rajesh Rajendran/rjshrjndrn/g"`;
GIT_COMMITTER_EMAIL=`echo $GIT_COMMITTER_EMAIL | sed -e "s/rjshrjndrn@.*/rjshrjndrn@github.com/g"`;
' \
--tag-name-filter cat -- --all # If you want to change the entire repo
# Change the commit message.
# Here dropping a line.
# https://stackoverflow.com/questions/19636750/git-filter-branch-msg-filter-to-reword-a-pushed-commit-message
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch -f --msg-filter \
'sed "s/accident secret//g"' \
--tag-name-filter cat -- --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment