git filter-branch --env-filter \'
export GIT_AUTHOR_EMAIL=\"foo@example.com\"
export GIT_AUTHOR_NAME=\"foo\"\' -- commita..commitb
Results in
Enclose you filter commands in an if-statement that checks for that range. You can check whether a commit is within a given range with this command:
git rev-list start..end | grep **fullsha**
The current commit will be stored in $GIT_COMMIT in your filter. So your filter becomes:
git filter-branch --env-filter '
if git rev-list commita..commitb | grep $GIT_COMMIT; then
export GIT_AUTHOR_EMAIL="foo@example.com"
export GIT_AUTHOR_NAME="foo"
fi' -- ^commita --all
If you want to only rewrite your current branch, replace --all with HEAD