You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何将未关联GitHub账号的1500+本地邮箱提交记录关联至账号?

如何将Git历史提交关联到你的GitHub账号

Absolutely, you can fix this by rewriting your Git repository's history to replace the old local email with your verified GitHub email—here's a step-by-step guide tailored for your scenario with 1500+ commits:

1. 先备份仓库(关键!)

First, create a mirror clone of your repository to work on—this ensures you don't mess up the original repo if something goes wrong:

git clone --mirror https://github.com/your-username/your-repo.git
cd your-repo.git

2. 编写批量修改脚本

We'll use git filter-repo (the modern replacement for the deprecated git filter-branch) to rewrite all commits with your correct GitHub-associated identity. Create a script file named update-commits.sh with this content:

git filter-repo --mailmap <<'EOF'
# Replace these values with your actual details
Your GitHub Display Name <your-verified-github-email@example.com> Your Old Name <old-local-email@server.local>
EOF
  • Important: Replace Your GitHub Display Name with the name linked to your GitHub account, your-verified-github-email@example.com with the email you've added and verified on GitHub, and Your Old Name/old-local-email@server.local with the identity from your old commits.
  • If you have multiple old name/email combinations (e.g., different spellings of your name), add additional lines to the mailmap section, one per combination.

3. 执行修改并验证

Run the script to rewrite the history:

bash update-commits.sh

After it finishes, verify that all commits now use your correct identity by checking the log:

git log --pretty=format:"%an <%ae>"

Double-check that every entry shows your GitHub name and verified email.

4. 强制推送修改后的历史

Once you're confident the changes are correct, push the rewritten history to GitHub. Note: This will overwrite the remote repository's history, so make sure to notify any collaborators first—they'll need to re-clone the repo or rebase their local work to avoid conflicts.

git push --force

后续注意事项

  • GitHub may take a few hours to reprocess your commits and update your contribution graph and project statistics—don't panic if you don't see changes immediately.
  • Ensure your new email is verified in your GitHub account settings (under Settings > Emails) otherwise GitHub won't associate the commits with your profile.

内容的提问来源于stack exchange,提问作者Sølve

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 09:52:59