The GH007 error occurs when GitHub's email privacy settings block a push because your commits contain your private email address. Fix it by configuring Git to use GitHub's noreply email address, then amend the offending commits.
This error means GitHub has detected that one or more of your commits contain your private email address, and your account is configured to block such pushes. GitHub's email privacy feature prevents accidental exposure of your personal email address in commit history. When you enable "Keep my email addresses private" in your GitHub settings, GitHub provides you with a special noreply email address in the format `{ID}+{username}@users.noreply.github.com`. If you also enable "Block command line pushes that expose my email," GitHub will reject any push that contains commits authored with your real email address. This is a privacy protection feature, not an error in the traditional sense. GitHub is actively protecting your personal information from being permanently embedded in public commit history. Once a commit with your email is pushed to a public repository, it becomes part of the permanent Git history and can be scraped by bots or accessed by anyone.
First, you need to locate your GitHub-provided noreply email address:
1. Go to [github.com/settings/emails](https://github.com/settings/emails)
2. Look for the "Keep my email addresses private" checkbox
3. Below it, you'll see text containing your noreply address in this format:
{ID}+{username}@users.noreply.github.comFor example: [email protected]
Copy this address - you'll need it for the next steps.
Note: The numeric ID is unique to your account and helps GitHub link commits to your profile even when using the noreply address.
Update your Git configuration to use the noreply email for all future commits:
For all repositories (recommended):
git config --global user.email "{ID}+{username}@users.noreply.github.com"For the current repository only:
git config user.email "{ID}+{username}@users.noreply.github.com"Verify the configuration:
git config user.email
# Should output: {ID}+{username}@users.noreply.github.comReplace {ID}+{username} with your actual noreply address from the previous step.
If your most recent commit contains your private email, amend it to use the new configuration:
git commit --amend --reset-author --no-editThis command:
- --amend: Modifies the last commit instead of creating a new one
- --reset-author: Updates the author info to match your current Git config
- --no-edit: Keeps the same commit message
Try pushing again:
git pushIf successful, you're done! If you have multiple commits with the private email, continue to the next step.
If several commits contain your private email, you'll need to rewrite them. First, find how many commits have the issue:
git log --oneline | head -10For a few recent commits (soft reset approach):
# Reset to before the problematic commits (keeping changes)
git reset --soft HEAD~3 # Adjust number as needed
# Re-commit all changes with correct email
git commit -m "Your commit message"For many commits (rebase approach):
# Start interactive rebase (adjust number of commits)
git rebase -i HEAD~5
# In the editor, change 'pick' to 'edit' for commits needing email fix
# Save and close the editor
# For each commit that pauses:
git commit --amend --reset-author --no-edit
git rebase --continue
# Repeat until rebase completesWarning: Rewriting history changes commit hashes. If you've already pushed these commits, you'll need to force push (see Advanced Notes).
After fixing the commits, push to GitHub:
git pushIf you rewrote commits that were already pushed, you'll need to force push:
# Force push (use with caution!)
git push --force-with-leaseThe --force-with-lease flag is safer than --force because it will fail if someone else has pushed to the branch since your last fetch.
Important: Only force push to branches you own. Never force push to shared branches like main without team coordination.
If you intentionally want to use your real email in commits and accept the privacy implications:
1. Go to [github.com/settings/emails](https://github.com/settings/emails)
2. Find "Block command line pushes that expose my email"
3. Uncheck this option
This allows pushes with your real email but removes GitHub's privacy protection.
Consider these implications:
- Your email becomes publicly visible in commit history
- Email harvesting bots may scrape your address
- You cannot retroactively hide the email from pushed commits
- Spam and phishing targeting developers is common
Recommendation: Keep the blocking enabled and use the noreply address instead.
### Why GitHub Uses This Protection
Email privacy is important because:
1. Commit history is permanent - Once pushed, emails in commits are part of the immutable Git history
2. Public repositories expose all committer emails - Anyone can view or scrape this data
3. Developer-targeted phishing is common - Email harvesters target developer emails for phishing campaigns
4. Professional/personal separation - Many developers prefer to keep work and personal identities separate
### Contribution Graph and Noreply Emails
Using GitHub's noreply address does not affect your contribution graph. GitHub links the noreply address to your account using the unique numeric ID prefix. Your commits will still:
- Count toward your contribution graph
- Show your profile picture and username
- Link back to your GitHub profile
### Handling Pre-existing Repositories
If you have many repositories with old commits containing your private email, you have options:
Option 1: Fix only new commits going forward
Just configure the noreply email - old commits remain unchanged but new ones will be correct.
Option 2: Rewrite entire repository history
# WARNING: This rewrites ALL commit hashes
git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_EMAIL="{ID}+{username}@users.noreply.github.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tagsOr use the modern alternative, git-filter-repo:
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"
'### IDE and Git GUI Configuration
Some IDEs cache Git configuration. Make sure to update email settings in:
- VS Code: Settings > Git: User Email
- IntelliJ/WebStorm: Settings > Version Control > Git > User Name/Email
- GitKraken: Preferences > Profiles
- Sourcetree: Tools > Options > General
### Multiple GitHub Accounts
If you use multiple GitHub accounts (e.g., personal and work), configure email per-repository or use Git's conditional includes:
# ~/.gitconfig
[includeIf "gitdir:~/work/"]
path = ~/.gitconfig-work
[includeIf "gitdir:~/personal/"]
path = ~/.gitconfig-personalThen in ~/.gitconfig-work:
[user]
email = {ID}[email protected]### Enterprise GitHub and Email Privacy
GitHub Enterprise may have different email privacy settings controlled by your organization. Contact your GitHub administrator if:
- The noreply email format differs from standard GitHub
- Email privacy options are not available
- Organization policies require specific email domains
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