This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Line three |
This comment has been minimized.
This comment has been minimized.
What if we have multiple old emails? This though might be useful: #!/bin/sh
# see https://help.github.com/articles/changing-author-info/
git filter-branch --env-filter '
OLD_EMAIL=(
"your-old-email@example.com"
"your-git-email@users.noreply.github.com"
)
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
for NEW_EMAIL in ${OLD_EMAIL[@]}; do
if [ "$GIT_COMMITTER_EMAIL" == "$NEW_EMAIL" ]; then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" == "$NEW_EMAIL" ]; then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
done
' --tag-name-filter cat -- --branches --tags |
This comment has been minimized.
This comment has been minimized.
@shivapoudel good enhancement It could be done a case insensitive OLD_EMAIL search too (see my fork) |
This comment has been minimized.
This comment has been minimized.
@gchicareli Don't work for me I have this |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
It worked as it is for me but I had to checkout every branch manually and run it. |
This comment has been minimized.
This comment has been minimized.
I've moved one of my personal script related to this and made a command for it in https://github.com/tj/git-extras/ |
This comment has been minimized.
This comment has been minimized.
In case you also want to change commits with a specific author name:
My fork: https://gist.github.com/frz-dev/adf8c2c7275da1369e0cc340feda0ba0 |
This comment has been minimized.
This comment has been minimized.
@frz-dev Awesome! Thanks |
This comment has been minimized.
This comment has been minimized.
On mac when I added quotes around my OLD_EMAIL, etc. in quotes some extra characters got added in my name (escape chars?). Then I had to make my OLD_EMAIL as my CORRECT_EMAIL with quotes and add CORRECT_NAME and CORRECT_EMAIL without quotes. This resolved everything and linked my commits properly. |
This comment has been minimized.
This comment has been minimized.
This is my stab at making this script a bit more usable: TL;DR?the following changes makes it possible to use the script like this: > git rewrite-author your-old-email@example.com your-name your-new-email@example.com changes to
|
This comment has been minimized.
This comment has been minimized.
I also wrote a convenient script to easily rewrite author/committer name and/or email. |
This comment has been minimized.
git filter-branch --env-filter '
OLD_EMAIL="chicareligerson@icloud.com"
CORRECT_NAME="Gerson Chicareli"
CORRECT_EMAIL="chicareligerson@icloud.com"
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