Created
March 10, 2018 21:07
-
-
Save colindean/fabf0846883c0d278ce729c773eb6f51 to your computer and use it in GitHub Desktop.
Git user.email mass changer
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
#!/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