GitHub blocks your push with GH007 when commits contain your private email address and email privacy protection is enabled. Configure Git to use GitHub's noreply email and rewrite the problematic commits to resolve this.
This error occurs when GitHub's email privacy protection detects that your push contains commits authored with your private email address. GitHub is blocking the push to prevent your personal email from being exposed in the public commit history. When you enable "Keep my email addresses private" in your GitHub account settings, GitHub assigns you a special noreply email address formatted as `{ID}+{username}@users.noreply.github.com`. If you also enable "Block command line pushes that expose my email," GitHub will reject any push where commits are authored with an email address other than the noreply address. This is a privacy safeguard, not a repository or authentication problem. Git commits contain the author's email address as metadata, and once commits are pushed to a public repository, this information becomes permanently visible to anyone who clones or views the repository. Spammers and phishing campaigns frequently scrape developer email addresses from public repositories.
Navigate to your GitHub email settings to find your noreply address:
1. Go to [github.com/settings/emails](https://github.com/settings/emails)
2. Locate the "Keep my email addresses private" section
3. Your noreply address appears below this option in the format:
{ID}+{username}@users.noreply.github.comExample: [email protected]
Copy this complete address including the numeric ID prefix - you'll need it for configuring Git.
The numeric ID uniquely identifies your account, allowing GitHub to properly attribute commits made with the noreply address to your profile.
Configure Git to use your GitHub noreply email for all commits:
Global configuration (applies to all repositories):
git config --global user.email "{ID}+{username}@users.noreply.github.com"Repository-specific configuration:
git config user.email "{ID}+{username}@users.noreply.github.com"Verify the configuration:
git config user.emailThis should output your noreply email address. Replace the placeholder with your actual noreply address from Step 1.
New commits will now use the noreply address automatically.
If only your latest commit contains the private email, amend it to update the author information:
git commit --amend --reset-author --no-editExplanation:
- --amend: Modifies the most recent commit
- --reset-author: Updates the author email to your current Git configuration
- --no-edit: Preserves the existing commit message
Attempt the push again:
git pushIf the push succeeds, you're done. If multiple commits contain your private email, proceed to the next step.
When several commits contain your private email, you need to rewrite their history.
Identify affected commits:
git log --format='%h %ae %s' | head -20For a small number of recent commits (soft reset):
# Reset to before problematic commits, keeping changes staged
git reset --soft HEAD~3 # Adjust the number as needed
# Create new commit(s) with the correct email
git commit -m "Your commit message"For more commits (interactive rebase):
# Start interactive rebase for the last N commits
git rebase -i HEAD~5
# In the editor, change 'pick' to 'edit' for each commit needing the fix
# Save and close
# For each paused commit:
git commit --amend --reset-author --no-edit
git rebase --continue
# Repeat until completeNote: Rewriting commits changes their SHA hashes, which affects collaboration if commits were already pushed.
Push your fixed commits to GitHub:
git pushIf the commits were already on the remote and you rewrote them, you'll need to force push:
git push --force-with-leaseUsing --force-with-lease instead of --force adds a safety check that prevents overwriting work pushed by others since your last fetch.
Caution: Only force push to branches where you're the sole contributor, or coordinate with your team first. Never force push shared branches like main without explicit agreement.
If you prefer using your real email in commits and understand the privacy implications:
1. Visit [github.com/settings/emails](https://github.com/settings/emails)
2. Find "Block command line pushes that expose my email"
3. Uncheck this option
Privacy considerations:
- Your email will be visible in commit history to anyone viewing the repository
- Public repositories expose emails to scrapers and bots
- Developer-targeted phishing and spam is prevalent
- Email exposure in commits cannot be undone after pushing
Recommendation: Using the noreply email provides privacy protection while maintaining full commit attribution to your GitHub profile.
### Understanding GitHub's Email Privacy Protection
GitHub implemented email privacy features because:
1. Commit metadata is permanent - Email addresses in commits become part of immutable Git history
2. Public exposure risk - Anyone can view or clone public repositories and extract committer emails
3. Targeting developers - Phishing campaigns specifically target developers using harvested emails
4. Professional boundaries - Developers often want separation between personal and professional identities
### Contribution Tracking with Noreply Email
Commits using GitHub's noreply address are fully attributed to your account:
- Contributions appear on your profile
- Contribution graph updates correctly
- Commits link to your profile when viewed
- Your avatar displays next to commits
The numeric ID in the noreply address enables GitHub to make this connection.
### Rewriting Entire Repository History
For repositories with extensive history containing your private email:
Using git-filter-repo (recommended modern approach):
pip install git-filter-repo
git filter-repo --email-callback '
return email if email != b"[email protected]" else b"{ID}+{username}@users.noreply.github.com"
'Using git filter-branch (legacy approach):
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
NEW_EMAIL="{ID}+{username}@users.noreply.github.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]; then
export GIT_COMMITTER_EMAIL="$NEW_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]; then
export GIT_AUTHOR_EMAIL="$NEW_EMAIL"
fi
' --tag-name-filter cat -- --branches --tagsWarning: These operations rewrite all commit hashes and require force pushing all branches.
### IDE Configuration
Update email settings in your development environment:
- VS Code: File > Preferences > Settings > search "git email"
- JetBrains IDEs: Settings > Version Control > Git
- GitKraken: File > Preferences > Profiles
- Sourcetree: Tools > Options > General tab
### Managing Multiple GitHub Accounts
When working with multiple GitHub accounts, use conditional Git configuration:
# ~/.gitconfig
[user]
name = Your Name
[includeIf "gitdir:~/work/"]
path = ~/.gitconfig-work
[includeIf "gitdir:~/personal/"]
path = ~/.gitconfig-personal# ~/.gitconfig-work
[user]
email = {ID}[email protected]# ~/.gitconfig-personal
[user]
email = {ID}[email protected]### GitHub Enterprise Considerations
GitHub Enterprise Server may have different email privacy options controlled by organization policies. If you encounter this error on GitHub Enterprise:
- Check with your administrator for organization-specific noreply email formats
- Some organizations may disable email privacy features
- Enterprise policies may require specific email domains for commits
warning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server