Modify Git Log Mail
Use the following command to replace commit email and author information:
git filter-branch --env-filter '
if [ "$GIT_COMMITTER_EMAIL" = "old@example.com" ]
then
export GIT_COMMITTER_NAME="new"
export GIT_COMMITTER_EMAIL="new@example.com"
fi
if [ "$GIT_AUTHOR_EMAIL" = "old@example.com" ]
then
export GIT_AUTHOR_NAME="new"
export GIT_AUTHOR_EMAIL="new@example.com"
fi
' -- --all
Description
This command rewrites the author and committer information for all commits in the entire Git repository history.
If a commit contains the specified old email address old@example.com
, it will be replaced with the new username and email.
Logic Details
- Traverse the entire repository history (
-- --all
refers to all branches) - For each commit:
- If
GIT_AUTHOR_EMAIL
isold@example.com
, change the author name tonew
and email tonew@example.com
- If
GIT_COMMITTER_EMAIL
isold@example.com
, change the committer name to the same new values
- If
- The result is a completely rewritten version of the history, with all commit information updated to the new identity
No comments to display
No comments to display