Skip to content

Instantly share code, notes, and snippets.

@kijtra
Last active May 15, 2020 08:18
Show Gist options
  • Save kijtra/45cc8fa5603097bb9ab22aa5795971c1 to your computer and use it in GitHub Desktop.
Save kijtra/45cc8fa5603097bb9ab22aa5795971c1 to your computer and use it in GitHub Desktop.
Gitで過去のコミットのAuthorとCommitterを一括変更する
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="new-user-name"
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
# AND push the corrected history
#
# git push --force --tags origin 'refs/heads/*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment