Recently I needed to change the author of all the commits in the repository. And here is how I achieved that.
Created a file edit_commits.sh
and put a script there.
#!/bin/sh
git filter-branch -f --env-filter '
CORRECT_NAME="Your Name"
CORRECT_EMAIL="yourcorrect@email.com"
if [ "$GIT_COMMITTER_EMAIL" != "$CORRECT_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" != "CORRECT_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
Then saved it and launched by the command.
bash edit_commits.sh
And that's it. Enjoy!
Top comments (0)