Skip to content

Instantly share code, notes, and snippets.

@jotajr
Last active February 15, 2023 18:08
Show Gist options
  • Save jotajr/2f3135029e564d62a993dd4e251c0566 to your computer and use it in GitHub Desktop.
Save jotajr/2f3135029e564d62a993dd4e251c0566 to your computer and use it in GitHub Desktop.
[GIT] Renomear os emails de um repositório Git
#!/bin/sh
# Faz o clone de uma nova versão do repositório
# git clone --bare https://github.com/user/repo.git
# cd repo.git
# Execute este script
echo "Alterando os commits com o novo autor"
git filter-branch --env-filter '
OLD_EMAIL="j.freitas.junior@accenture.com"
CORRECT_NAME="Jota Freitas Jr"
CORRECT_EMAIL="jotafreitasjr@gmail.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
echo "Final do script!"
echo "Execute o seginte comando:"
echo "git push --force --tags origin 'refs/heads/*'"
echo "Apos a execucao remova o repositório!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment