#!/bin/bash if [ -z $1 ]; then echo "Usage $0 LAST_CORRECT_COMMIT" exit 0 fi git filter-branch --env-filter 'export GIT_COMMITTER_NAME="Pedro Sanção"; export GIT_COMMITTER_EMAIL="pedrosancao@users.noreply.github.com"; export GIT_AUTHOR_NAME="Pedro Sanção"; export GIT_AUTHOR_EMAIL="pedrosancao@users.noreply.github.com"; export GIT_AUTHOR_DATE="$GIT_COMMITTER_DATE"' $1..HEAD # sample with ifs from https://stackoverflow.com/a/61765245/2932525 # OLD_EMAIL="your-old-email@example.com" # CORRECT_NAME="Your Correct Name" # CORRECT_EMAIL="your-correct-email@example.com" # if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ] # then # export GIT_COMMITTER_NAME="$CORRECT_NAME" # export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL" # fi # if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] # then # export GIT_AUTHOR_NAME="$CORRECT_NAME" # export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL" # fi