Created
June 10, 2023 04:37
-
-
Save alexperronnet/ad97a32a127e3d0f873ad421ca0f056b to your computer and use it in GitHub Desktop.
Update the email linked to your previous commit after changing your email address.
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 | |
set -e | |
username="" | |
new_email="" | |
repos=( | |
# Add the list of repos here | |
) | |
old_emails=( | |
# Add the list of old emails here | |
) | |
for repo in "${repos[@]}" | |
do | |
git clone "git@github.com:${username}/${repo}.git" | |
cd "${repo}" | |
for old_email in "${old_emails[@]}" | |
do | |
git filter-branch --env-filter " | |
if [ \"\$GIT_COMMITTER_EMAIL\" = \"${old_email}\" ] | |
then | |
export GIT_COMMITTER_EMAIL=\"${new_email}\" | |
fi | |
if [ \"\$GIT_AUTHOR_EMAIL\" = \"${old_email}\" ] | |
then | |
export GIT_AUTHOR_EMAIL=\"${new_email}\" | |
fi | |
" -f --tag-name-filter cat -- --branches --tags | |
done | |
git push --force --tags origin 'refs/heads/*' | |
cd .. | |
rm -rf "${repo}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment