Use github script to change commit's author

https://help.github.com/articles/changing-author-info/
This commit is contained in:
gardouille 2016-07-06 14:27:41 +02:00
parent 0a4fce1f29
commit 7432d6dd96

View File

@ -1,13 +1,22 @@
#!/bin/sh
git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "OLD_USERNAME" ];
git filter-branch --env-filter '
OLD_EMAIL="old_username@email"
CORRECT_NAME="LastName FirstName"
CORRECT_EMAIL="username@email"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
GIT_COMMITTER_NAME="NEW_USERNAME";
GIT_AUTHOR_NAME="NEW_USERNAME";
GIT_COMMITTER_EMAIL="EMAIL_NEW_USERNAME";
GIT_AUTHOR_EMAIL="EMAIL_NEW_USERNAME";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
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
printf '%b' "You can check you git history, then run:\n"
printf '%b' "git push --force --tags origin 'refs/heads/*'"
exit 0