修改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_EMAILCORRECT_NAMECORRECT_EMAIL改成 需要修改的新旧邮箱用户名即可

相关文章:

  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
  • 2021-10-10
  • 2022-12-23
  • 2021-05-21
  • 2021-05-13
猜你喜欢
  • 2022-01-15
  • 2021-08-21
  • 2021-12-07
  • 2021-09-14
  • 2022-01-09
  • 2022-01-15
相关资源
相似解决方案