Last active
April 14, 2020 14:49
-
-
Save BILLthebuilder/87750326a34367bdaa7ffce4391889a3 to your computer and use it in GitHub Desktop.
A simple script to rewrite your commit email address. Use it at your own risk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# simple script to change commit email address | |
# Change the values as per your use case | |
# After cloning this or downloading this | |
# Navigate to the directory | |
# run: `chmod u+x gitemail.sh` to make it executable | |
# copy the script in your intended repository | |
# run ./gitemail.sh and wait for the magic to happen | |
# I'm not responsible for any unintended consenquences | |
git filter-branch --force --env-filter ' | |
OLD_EMAIL="the email you want to change" | |
CORRECT_NAME="Prefferred username" | |
CORRECT_EMAIL="Preffered email" | |
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 | |
git push --force --tags origin 'refs/heads/*' | |
# Author: https://github.com/BILLthebuilder |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment