Error while setting up Git with Github

Hi folks,
I am working on the following exercise:

https://www.codecademy.com/paths/full-stack-engineer-career-path/tracks/fscp-git-and-github-part-i/modules/fecp-introduction-to-github/articles/f1-u3-git-setup

trying to set up my first remote repository and when I run the command on my terminal, I get the following error message:

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: github url
To github url
! [remote rejected] main → main (push declined due to email privacy restrictions)
error: failed to push some refs to ‘github url’

Thank you in advance for your help.

Dennis

Hello, and welcome to the forums!

It seems that you turned on these options in GitHub:

but when you configured the email address for git to use locally, you probably used the email address associated with GitHub rather than the one they generated for you to use for privacy. You should use the email address from the spot I blurred out in the previous screenshot. It will be personalized for you in the GitHub settings under Emails.

You can reconfigure it using:

git config --global user.email "private_email_from_github@here.com"

That will solve the issues for new git repositories you create locally from now on.

However, it won’t retroactively fix the ones you already created.

  • If you’ve only created a test repository, this won’t be a problem because you can start over.
  • If you have a long history of git commits that you want to keep, then the solutions to change the author information of previous commits can be quite involved and dangerous. Here’s an article that discusses some options to do that if you want: Editing the Author of Past Commits

Alternatively, you could uncheck the “Block command line pushes that expose my email” in GitHub’s settings.

3 Likes

I have a bit similar issue when trying to git push -u origin main:
image
The command prompt just gets stuck there and does nothing. The only option for me is to CTRL+C.

I’ve already checked that I’m using HTTPS:
image

Does anybody know how I can overcome this issue? I’ve been struggling for an hour and googling hasn’t helped either.

I’m facing this issue while copying the said code on #5 of the topic " Your First Remote Repository on GitHub" on this lesson

I feel clueless and can someone help in overcoming this?
image

That seems to be a different error. That warning commonly pops up when no commits have been made within the repository.

It can occur under other circumstances- Message 'src refspec master does not match any' when pushing commits in Git - Stack Overflow but at a guess it’s that no commits have yet been made.

If your push actually hangs after you’ve made some commits then look into getting the most recent release of git for windows that has now patched the issue-