Skip to content

Instantly share code, notes, and snippets.

@alexperronnet
Created June 10, 2023 04:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexperronnet/ad97a32a127e3d0f873ad421ca0f056b to your computer and use it in GitHub Desktop.
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.
#!/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