Commit 5865620d authored by Glen Mével's avatar Glen Mével

`git-change-author`: replace an author by another in git history

parent 252e6329
#!/bin/sh
# USAGE:
# git-change-author OLD_MAIL NEW_MAIL NEW_NAME
# Rewrite the Git history, substituting all occurrences of a given author.
# Adapted from https://help.github.com/articles/changing-author-info/
if [ $# -ne 3 ] ; then
echo>&2 "Usage: $0 OLD_MAIL NEW_MAIL NEW_NAME"
exit 1
fi
OLD_MAIL="$1"
NEW_MAIL="$2"
NEW_NAME="$3"
exec git filter-branch --env-filter '
OLD_MAIL='$(printf %q "$OLD_MAIL")'
NEW_MAIL='$(printf %q "$NEW_MAIL")'
NEW_NAME='$(printf %q "$NEW_NAME")'
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_MAIL" ]
then
export GIT_COMMITTER_NAME="$NEW_NAME"
export GIT_COMMITTER_EMAIL="$NEW_MAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_MAIL" ]
then
export GIT_AUTHOR_NAME="$NEW_NAME"
export GIT_AUTHOR_EMAIL="$NEW_MAIL"
fi
' --tag-name-filter cat -- --branches --tags
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment