Created
December 26, 2025 20:28
-
-
Save petrusnog/a6a64db97b331141bf03e4724f6c634d to your computer and use it in GitHub Desktop.
Automatic change between work and personal email on git --global user.email.
This file contains hidden or 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
| #!/bin/bash | |
| # Script para alternar entre emails do git | |
| PERSONAL_EMAIL="personal@mail.com" | |
| WORK_EMAIL="work@mail.com" | |
| # Obter email atual | |
| CURRENT_EMAIL=$(git config --global user.email) | |
| if [ "$CURRENT_EMAIL" == "$PERSONAL_EMAIL" ]; then | |
| git config --global user.email "$WORK_EMAIL" | |
| echo "✓ Email alterado para: $WORK_EMAIL (Trabalho)" | |
| elif [ "$CURRENT_EMAIL" == "$WORK_EMAIL" ]; then | |
| git config --global user.email "$PERSONAL_EMAIL" | |
| echo "✓ Email alterado para: $PERSONAL_EMAIL (Pessoal)" | |
| else | |
| # Se não estiver configurado ou for outro email, define como pessoal por padrão | |
| git config --global user.email "$PERSONAL_EMAIL" | |
| echo "✓ Email configurado para: $PERSONAL_EMAIL (Pessoal)" | |
| fi | |
| # Mostrar configuração atual | |
| echo "" | |
| echo "Configuração atual do Git:" | |
| echo "Nome: $(git config --global user.name)" | |
| echo "Email: $(git config --global user.email)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment