变更Github上历史commit的用户名和邮箱的方法
kensoz -环境Window 10Git Bash先确认历史记录
错误的用户名是wrongName
,邮箱是[email protected]
git log --pretty=full
commit 000111000111000111000 (HEAD -> master, origin/master)
Author: wrongName <[email protected]>
Commit: wrongName <[email protected]>
变更方法设置正确的用户名
newName=correctName
设置正确的邮箱
[email protected]
修改本地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 <[email protected]>
Commit: correctName <[email protected]>
GitHub强行push,把刚才修改的提交到github
git push -f
特别申明:本文内容来源网络,版权归原作者所有,如有侵权请立即与我们联系(cy198701067573@163.com),我们将及时处理。
上一篇: Git 命令清单
下一篇: 如何使用 Git 管理配置文件