Skip to content

Instantly share code, notes, and snippets.

@makesomelayouts
Last active November 6, 2025 06:21
Show Gist options
  • Select an option

  • Save makesomelayouts/cf3c7359c75e9493afd7f8870d41bb4e to your computer and use it in GitHub Desktop.

Select an option

Save makesomelayouts/cf3c7359c75e9493afd7f8870d41bb4e to your computer and use it in GitHub Desktop.
a good solution to change commits author.

Source Video Source Code

  1. clone your repository with bare tag
git clone --bare https://github.com/yournickname/reponame.git
  1. go to your repository
cd reponame.git
  1. download script that i put here -> 'replace-git-commit-author.sh'

  2. move into your repository.git

  3. edit script to your: email that you wanna change, email and name that will be to changed instead.

OLD_EMAIL=""
CORRECT_NAME=""
CORRECT_EMAIL=""
  1. run script (to run bash scripts you need: git bash or WSL)
./replace-git-commit-author.sh
  1. push only tags i guess
git push --force --tags origin 'refs/heads/*'

!! and if u have multiple old emails to check, then u can use script: replace-all.sh

#!/bin/sh
CORRECT_NAME="makesomelayouts"
CORRECT_EMAIL="[email protected]"
OLD_EMAILS="@gmail.com @gmail.com"
git filter-branch --env-filter '
match_old_email() {
for e in '"$OLD_EMAILS"'; do
if [ "$1" = "$e" ]; then
return 0
fi
done
return 1
}
if match_old_email "$GIT_COMMITTER_EMAIL"; then
export GIT_COMMITTER_NAME="'"$CORRECT_NAME"'"
export GIT_COMMITTER_EMAIL="'"$CORRECT_EMAIL"'"
fi
if match_old_email "$GIT_AUTHOR_EMAIL"; then
export GIT_AUTHOR_NAME="'"$CORRECT_NAME"'"
export GIT_AUTHOR_EMAIL="'"$CORRECT_EMAIL"'"
fi
' --tag-name-filter cat -- --branches --tags
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL=""
CORRECT_NAME=""
CORRECT_EMAIL=""
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment