Skip to content

Instantly share code, notes, and snippets.

@rmtsrc
Created January 30, 2021 15:27
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 rmtsrc/8000ec884c88320aeaba0dbbe96682df to your computer and use it in GitHub Desktop.
Save rmtsrc/8000ec884c88320aeaba0dbbe96682df to your computer and use it in GitHub Desktop.
Update all old email addresses in commits from all existing GitHub repos
# Requires `git filter-repo` https://github.com/newren/git-filter-repo
mkdir tmp && cd tmp
export USERNAME="github-username"
export TOKEN="github-token-with-repo-access"
curl -u "$USERNAME:$TOKEN" "https://api.github.com/search/repositories?q=user:$USERNAME" |
grep -e 'ssh_url*' |
cut -d \" -f 4 |
xargs -L1 git clone
for d in ./*/ ; do
pushd "$d"
# ../my-mailmap
# New Name <new@email.com> <old@email.com>
# New Name <new@email.com> <different-old@email.com>
# etc.
git filter-repo --mailmap ../my-mailmap
git remote add origin git@github.com:$USERNAME/${PWD##*/}.git
git push --force origin master
popd
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment