Skip to content

Instantly share code, notes, and snippets.

@colindean
Created March 10, 2018 21:07
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 colindean/fabf0846883c0d278ce729c773eb6f51 to your computer and use it in GitHub Desktop.
Save colindean/fabf0846883c0d278ce729c773eb6f51 to your computer and use it in GitHub Desktop.
Git user.email mass changer
#!/usr/bin/env bash
# Did your company change its email domain?
# Use this handy script to change all of your git repos quickly and easily!
# Don't worry, it'll only the change the repos where user.email was set to the old one!
# Usage: change_emails.bash username old_domain new_domain
# Example: change_emails.bash maxine.mustermann boringdomain.com exciting.io
EMAIL_USER="$1"
OLD_DOMAIN="$2"
NEW_DOMAIN="$3"
change_email() {
pushd $1;
if [[ "$(git config user.email)" == "${EMAIL_USER}@${OLD_DOMAIN}" ]]; then
git config user.email "${EMAIL_USER}@${NEW_DOMAIN}";
fi;
popd;
}
export -f change_email;
find $1 -iname ".git" -exec bash -c 'change_email "$0"' {} \;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment