#!/bin/bash (( $# != 4 )) && { echo "$0 " >&1 ; exit 1 ; } _repo="$1" _oldmail="$2" _newauthor="$3" _newmail="$4" cd "$_repo" || exit $? git filter-branch --force --commit-filter ' if [ "$GIT_AUTHOR_EMAIL" = "'"$_oldmail"'" ]; then export GIT_AUTHOR_NAME="'"$_newauthor"'"; export GIT_AUTHOR_EMAIL="'"$_newmail"'"; git commit-tree -S "$@" elif [ "$GIT_COMMITTER_EMAIL" = "'"$_oldmail"'" ]; then export GIT_COMMITTER_NAME="'"$_newauthor"'"; export GIT_COMMITTER_EMAIL="'"$_newmail"'"; git commit-tree -S "$@" fi' \ --tag-name-filter cat \ -- --branches --tags