Need to remove email address from commit history associated with closed PRs #209468
🏷️ Discussion TypeQuestion 💬 Feature/Topic AreaOther Discussion DetailsI have a private, personal repo which I want to make public (with MIT licence). Unfortunately, I accidentally made some commits using my work email address, despite the repo having nothing to do with work, containing no code associated with work, and having been done outside work hours. I am hesitant to make the repo public and add a licence with the work email address in the commits, but I can't edit commit metadata for closed PRs. Any way I can get the email address removed? I have fixed things for future commits and can re-write history for commits not part of closed PRs, so that's not a problem. It's just the read-only commits I'm struggling with. |
Replies: 3 comments 4 replies
|
Yes, you can absolutely remove your work email address from your entire repository history, including commits that were part of closed Pull Requests.. Step1:- Backup your Repo |
|
Hi @bensullivan2002, You cannot directly modify commit metadata inside closed Pull Requests because GitHub stores immutable internal references ( Since this is a private personal repository that hasn't been shared or made public yet, the definitive and cleanest solution is to rewrite the history locally, push it to a clean repository, and delete the old one. This completely purges all closed PRs and cached commit history. Here are the complete steps: Step 1: Install
|
|
The commits themselves don't actually contain your email address in a way that's publicly visible on GitHub — the email is stored in the git metadata but GitHub only displays it if the email isn't associated with a private account or if you have email privacy disabled. If you go to Settings > Emails and make sure "Keep my email address private" is on, GitHub will mask it in the web interface even on public repos. That said if you're worried about someone cloning the repo and running git log to pull the raw metadata, that's a legitimate concern and the only real fix is a history rewrite. For the closed PR commits specifically, GitHub support can help with removing sensitive data from repository history — there's a documented process at docs.github.com/en/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository using git-filter-repo, and if the PR closure is what's blocking you from doing it yourself, contacting support directly is the escalation path. |
Hi @bensullivan2002,
You cannot directly modify commit metadata inside closed Pull Requests because GitHub stores immutable internal references (
refs/pull/<id>/head) and cached commit objects that standardgit push --forcecannot overwrite.Since this is a private personal repository that hasn't been shared or made public yet, the definitive and cleanest solution is to rewrite the history locally, push it to a clean repository, and delete the old one. This completely purges all closed PRs and cached commit history.
Here are the complete steps:
Step 1: Install
git-filter-repoand rewrite the email locally