配置当前的用户名邮箱可以当前项目配置或者全局配置。

仅当前项目配置:

git config user.name 'your-user-name'
git config user.email 'your-user-email'

全局配置:

git config --global user.name 'your-user-name'
git config --global user.email 'your-user-email'

新建shell脚本 change-email-name.sh 内容如下:

#!/bin/sh

git filter-branch --env-filter '

OLD_EMAIL="your-old-email"
NEW_NAME="your-new-name"
NEW_EMAIL="your-new-email"

if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$NEW_NAME"
    export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$NEW_NAME"
    export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
将脚本放到项目根目录下,执行脚本:
./change-email-name.sh

如果执行失败,执行以下代码后再执行脚本:

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch Rakefile' HEAD

然后强行覆盖仓库

git push origin --force --all

 

 

 

 

 

相关文章:

  • 2022-12-23
  • 2021-06-29
  • 2021-05-21
  • 2021-11-30
  • 2021-12-08
  • 2022-02-08
  • 2022-12-23
猜你喜欢
  • 2022-02-08
  • 2022-02-25
  • 2021-10-14
  • 2022-02-08
  • 2022-01-28
  • 2021-06-24
  • 2021-09-14
相关资源
相似解决方案