Skip to content

Instantly share code, notes, and snippets.

@rmtsrc
Created January 30, 2021 15:27
Show Gist options
  • 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 <[email protected]> <[email protected]>
# New Name <[email protected]> <[email protected]>
# etc.
git filter-repo --mailmap ../my-mailmap
git remote add origin [email protected]:$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