Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Rewrite an author/committer in your git history. Place on your path and do: git change-committer name new_name new_email
#!/bin/bash
usage() {
echo "$0 usage:"
echo " $0 name new_name new_email"
exit 1
}
if [ "$#" -ne 3 ]; then
usage
fi
if ! git diff --quiet; then
echo "You have uncommitted changes."
exit 1
fi
export oa="$1"
export na="$2"
export ne="$3"
git filter-branch --env-filter '
an="$GIT_AUTHOR_NAME"
ae="$GIT_AUTHOR_EMAIL"
cn="$GIT_COMMITTER_NAME"
ce="$GIT_COMMITTER_EMAIL"
if [ "$an" = "$oa" ]; then
an="$na"
ae="$ne"
cn="$na"
ce="$ne"
fi
export GIT_AUTHOR_NAME="$an"
export GIT_AUTHOR_EMAIL="$ae"
export GIT_COMMITTER_NAME="$cn"
export GIT_COMMITTER_EMAIL="$ce"
'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.