Skip to content

Instantly share code, notes, and snippets.

@petrusnog
Created December 26, 2025 20:28
Show Gist options
  • Select an option

  • Save petrusnog/a6a64db97b331141bf03e4724f6c634d to your computer and use it in GitHub Desktop.

Select an option

Save petrusnog/a6a64db97b331141bf03e4724f6c634d to your computer and use it in GitHub Desktop.
Automatic change between work and personal email on git --global user.email.
#!/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