环境
- Window 10
- Git Bash
先确认历史记录
错误的用户名是wrongName
,邮箱是wrongMail@example.com
git log --pretty=full
commit 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=full
commit 000111000111000111000 (HEAD -> master, origin/master)
Author: correctName <correctMail@example.com>
Commit: correctName <correctMail@example.com>
GitHub
强行push,把刚才修改的提交到github
git push -f
相关文章
暂无评论...