Skip to content

Instantly share code, notes, and snippets.

@pathawks
Forked from jeresig/gist:199298
Last active December 20, 2015 19:59
Show Gist options
  • Save pathawks/6187165 to your computer and use it in GitHub Desktop.
Save pathawks/6187165 to your computer and use it in GitHub Desktop.
Change author information in past commits
#!/bin/sh
# Rename an email address in all old commits.
# WARNING: Will change all your commit SHA1s.
# Based off of the script from here:
# http://coffee.geek.nz/how-change-author-git.html
git filter-branch -f --env-filter '
an="$GIT_AUTHOR_NAME"
am="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
cm="$GIT_COMMITTER_EMAIL"
if [ "$GIT_AUTHOR_NAME" = "***Old Name***" ]
then
an="***New Name***"
am="[email protected]"
fi
if [ "$GIT_COMMITTER_NAME" = "***Old Name***" ]
then
cn="***New Name***"
cm="[email protected]"
fi
if [ "$GIT_AUTHOR_NAME" = "plugin-master" ]
then
an="plugin-master"
am="[email protected]"
fi
if [ "$GIT_COMMITTER_NAME" = "plugin-master" ]
then
cn="plugin-master"
cm="[email protected]"
fi
export GIT_AUTHOR_NAME="$an"
export GIT_AUTHOR_EMAIL="$am"
export GIT_COMMITTER_NAME="$cn"
export GIT_COMMITTER_EMAIL="$cm"
'
git push --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment