I am looking to edit the author/committer of several commits whose message is prefixed with [TEST].
I know that you can edit the authors with environment variables but I can't find it by searching with the commit message.
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Useername"
CORRECT_EMAIL="[email protected]"
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
' --tag-name-filter cat -- --branches --tags
We should be able to integrate a regex like this "[TEST]*":
if commit message = "[TEST]*" then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
Using the third-party git-filter-repo(1):
This Python callback (see manual) lets you change the commit in-place.
You will need to pass
--forceas well in order to do the change because this is a destructive update that cannot (in general) be undone.git-filter-branch(1)
git-filter-branch(1) is effectively deprecated and no one that I've seen has recommended its usage.