修改Git Commit提交记录的用户名Name和邮箱Email
修改Git 本次Commit提交记录的用户名Name和邮箱Email
git commit --amend --author="new-name <xxx@new.com>"
修改Git 全部Commit提交记录的用户名Name和邮箱Email
原文(有删改):https://cloud.tencent.com/developer/article/1352623
准备
在项目根目录下创建 email.sh 写入下面这段代码
#!/bin/sh
git filter-branch --env-filter '
# 要修改的邮箱
OLD_EMAIL="xxx@old.com"
# 新的邮箱以及用户名
CORRECT_NAME="your-name"
CORRECT_EMAIL="xxx@old.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch Rakefile' HEAD
把OLD_EMAIL、CORRECT_NAME、CORRECT_EMAIL改成 需要修改的新旧邮箱用户名即可
如果说我的文章对你有用,只不过是我站在巨人的肩膀上再继续努力罢了。
若在页首无特别声明,本篇文章由 Schips 经过整理后发布。
博客地址:https://www.cnblogs.com/schips/
若在页首无特别声明,本篇文章由 Schips 经过整理后发布。
博客地址:https://www.cnblogs.com/schips/

浙公网安备 33010602011771号