LoginSignup
15
14

More than 3 years have passed since last update.

【Git】push declined due to email privacy restrictionsへの対処法

Last updated at Posted at 2019-07-20

概要

GitHubで、Push時にメールアドレスで引っかかってエラーが発生した。

エラー文

$ git push origin master
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 4 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (9/9), 1.62 KiB | 1.62 MiB/s, done.
Total 9 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), done.
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: http://github.com/settings/emails
To github.com:~~~/~~~.git
 ! [remote rejected] master -> master (push declined due to email privacy restrictions)

エラーの内容

Eメールのプライバシー制限に引っかかってPushが拒否された(直訳)

原因と解決策

gitを使用するコミットユーザーのEmailに、Githubで非公開にしているメールアドレスを指定していたため。
Settings > Emails > Keep my email addresses private にチェックが入っていると、Githubでメールアドレスが非公開になっている。

その場合は、コミットユーザーのEmailに、代わりのものを使用する。
Settings > Emails > Primary email address の部分に、
[数字]+[ユーザー名]@users.noreply.github.com というものがあるので、それを指定してあげれば良い。

$ git config --global user.email [数字]+[ユーザー名]@users.noreply.github.com

追記

(19/07/20 22:10追記)
初期値では、「Block command line pushes that expose my email」がオフになっているようです。
これをオフにしている状態であれば、プライベートのメールアドレスもコミットユーザーのメールアドレスとしてPushできます。
(Pushはできますが警告が表示されます)
ご教授いただきありがとうございます!

15
14
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
14