Skip to content

Instantly share code, notes, and snippets.

@gengwg
Created February 16, 2026 18:25
Show Gist options
  • Select an option

  • Save gengwg/5e88db7d4d8eb3a72908eec6f163b0b7 to your computer and use it in GitHub Desktop.

Select an option

Save gengwg/5e88db7d4d8eb3a72908eec6f163b0b7 to your computer and use it in GitHub Desktop.
Enumerating objects: 19, done.
Counting objects: 100% (19/19), done.
Delta compression using up to 22 threads
Compressing objects: 100% (18/18), done.
Writing objects: 100% (18/18), 10.41 MiB | 4.59 MiB/s, done.
Total 18 (delta 2), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (2/2), completed with 1 local object.
remote: error: GH007: Your push would publish a private email address.
remote: You can make your email public or disable this protection by visiting:
remote: https://github.com/settings/emails
To github.com:gengwg/myrepo.git
 ! [remote rejected] master -> master (push declined due to email privacy restrictions)
error: failed to push some refs to 'github.com:gengwg/myrepo.git'

Your commit worked locally, but GitHub rejected the push because of its email privacy protection.

The key error is:

GH007: Your push would publish a private email address.

GitHub blocks pushes when:

  • Your commit email is not the GitHub-provided noreply email
  • AND you have “Keep my email address private” enabled

✅ Why This Happened

You configured Git as:

git config --global user.email "gengwg@xyz.com"

But in your GitHub account:

  • Your email is probably set to private
  • GitHub expects you to use a special noreply email

🔧 How to Fix It (Recommended Way)

Step 1 — Get Your GitHub noreply Email

  1. Go to: 👉 https://github.com/settings/emails
  2. Find your noreply email, it looks like:
12345678+gengwg@users.noreply.github.com

Copy it.


Step 2 — Update Git Config

Run:

git config --global user.email "12345678+gengwg@users.noreply.github.com"

(Replace with your actual noreply email.)


Step 3 — Fix the Last Commit

Since the commit was already created with the wrong email, amend it:

git commit --amend --reset-author

Then push again:

git push

🚀 Alternative Fix (Less Recommended)

You could instead:

  1. Go to GitHub email settings
  2. Uncheck "Keep my email address private"

Then your gengwg@xyz.com will work.

But most developers prefer using the noreply email.


🧠 Why This Is Good Practice

Using the noreply email:

  • Protects your personal email
  • Prevents spam
  • Keeps Git history clean
  • Still links commits to your GitHub account

🎯 Quick Summary

Best fix:

git config --global user.email "YOUR_NOREPLY_EMAIL"
git commit --amend --reset-author
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment