Open Zakariyya opened 4 years ago
要更改的作者/提交者字段中显示的旧电子邮件地址, 希望将正确名称和电子邮件地址作提交
tag: git | github | commit | author | 作者
git clone --bare https://github.com/user/repo.git cd repo.git
#!/bin/sh git filter-branch --env-filter ' OLD_EMAIL="your-old-email@example.com" CORRECT_NAME="Your Correct Name" CORRECT_EMAIL="your-correct-email@example.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 push --force --tags origin 'refs/heads/*'
清理临时克隆:
cd .. rm -rf repo.git
tag: git | github | commit | author | 作者
打开Git Bash
创建存储库的全新裸克隆:
复制并粘贴脚本,根据您收集的信息替换以下变量:
按Enter键运行脚本。
查看新的Git历史记录是否有错误。
将更正的历史记录推送到GitHub
清理临时克隆:
cd .. rm -rf repo.git
参考