git filter-branch --env-filter ' if test "$GIT_AUTHOR_EMAIL" = "<替换为原email>" then GIT_AUTHOR_NAME=<替换为新username> GIT_AUTHOR_EMAIL=<替换为新email> fi if test "$GIT_COMMITTER_EMAIL" = "<替换为原email>" then GIT_COMMITTER_NAME=<替换为新username> GIT_COMMITTER_EMAIL=<替换为新email> fi ' -- --all
如果提示如下信息:
1 2 3
Cannot create a new backup. A previous backup already exists in refs/original/ Force overwriting the backup with -f
可以加入-f参数强制执行
1 2 3 4 5 6 7 8 9 10 11 12
git filter-branch -f --env-filter ' if test "$GIT_AUTHOR_EMAIL" = "<替换为原email>" then GIT_AUTHOR_NAME=<替换为新username> GIT_AUTHOR_EMAIL=<替换为新email> fi if test "$GIT_COMMITTER_EMAIL" = "<替换为原email>" then GIT_COMMITTER_NAME=<替换为新username> GIT_COMMITTER_EMAIL=<替换为新email> fi ' -- --all