欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 编程资源 > 编程问答 >内容正文

编程问答

批量修改历史commit的用户名user.name邮箱user.email

发布时间:2025/4/14 编程问答 77 豆豆
生活随笔 收集整理的这篇文章主要介绍了 批量修改历史commit的用户名user.name邮箱user.email 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

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

仅当前项目配置:

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/shgit 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" ] thenexport GIT_COMMITTER_NAME="$NEW_NAME"export GIT_COMMITTER_EMAIL="$NEW_EMAIL" fi if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ] thenexport 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

 

 

 

 

 

转载于:https://www.cnblogs.com/Man-Dream-Necessary/p/10045350.html

总结

以上是生活随笔为你收集整理的批量修改历史commit的用户名user.name邮箱user.email的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。