环境
- Window 10
- Git Bash
先确认历史记录
谬误的用户名是wrongName
,邮箱是wrongMail@example.com
git log --pretty=fullcommit 000111000111000111000 (HEAD -> master, origin/master)Author: wrongName <wrongMail@example.com>Commit: wrongName <wrongMail@example.com>
变更办法
设置正确的用户名
newName=correctName
设置正确的邮箱
newEmail=correctMail@example.com
批改本地git的提交信息
git filter-branch -f --env-filter "GIT_AUTHOR_NAME='$newName'; GIT_AUTHOR_EMAIL='$newEmail'; GIT_COMMITTER_NAME='$newName'; GIT_COMMITTER_EMAIL='$newEmail';" HEAD
再确认历史记录,发现曾经被批改为正确的了
git log --pretty=fullcommit 000111000111000111000 (HEAD -> master, origin/master)Author: correctName <correctMail@example.com>Commit: correctName <correctMail@example.com>
GitHub
强行push,把方才批改的提交到github
git push -f