#!/bin/bash # # Rewrite identities in commits. # # Parameters BASENAME="`basename $0`" OLD_EMAIL="$1" NEW_EMAIL="$2" # Syntax check if [ -z "$3" ]; then echo "usage: $BASENAME " exit 1 fi # Get new name shift 2 NEW_NAME="$*" # Apply filter echo "Please run this command:" echo "" cat <<-EOF git filter-branch --commit-filter ' if [ "\$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]; then GIT_AUTHOR_NAME="$NEW_NAME"; GIT_AUTHOR_EMAIL="$NEW_EMAIL"; git commit-tree "\$@"; else git commit-tree "\$@"; fi' HEAD EOF # See https://stackoverflow.com/questions/7654822 echo "Done! Check results and remove the backup once you're ready:" echo "git update-ref -d refs/original/refs/heads/master"