LoginSignup
9
4

More than 3 years have passed since last update.

GitHubでメールアドレスを非公開にする

Last updated at Posted at 2021-03-29

はじめに

メモです。要点だけ書きます。

GitHubにおけるメールアドレスの役割

  • 通知メールアドレス
  • バックアップメールアドレス
  • コミットメールアドレス

恐らく、この3つです。

バックアップメールアドレス・コミットメールアドレスの詳しい説明や設定方法に関しては、GitHub 公式Document を参照してください。
https://docs.github.com/ja/github-ae@latest/github/setting-up-and-managing-your-github-user-account/managing-email-preferences

どうすべきか

GitHubサイト側の設定

https://github.com/settings/emails にアクセスすると、自分のアカウントのメールアドレス設定ができます。

  • Keep my email addresses private
  • Block command line pushes that expose my email

以上の2つにチェックがついていればひとまず安心です。

Primaryとマークがついているメールアドレスは デフォルトのメールアドレスになるほか、commit時にemail情報として含まれる可能性があります

メールアドレスを完全に非公開にしたい場合は、念のためローカル側で設定をする必要があります。

ローカル側の設定

$ git config --global user.email [ID]+[username]@users.noreply.github.com

[ID][username] は置き換えてください。
noreply メールアドレスは https://github.com/settings/emails に記載されています。

過去のコミットをすべて変更したいとき

参考:https://qiita.com/sea_mountain/items/d70216a5bc16a88ed932#%E9%81%8E%E5%8E%BB%E3%81%AE%E3%82%B3%E3%83%9F%E3%83%83%E3%83%88%E3%82%92%E3%81%99%E3%81%B9%E3%81%A6%E5%A4%89%E6%9B%B4%E3%81%97%E3%81%9F%E3%81%84%E3%81%A8%E3%81%8D

参考になりました

$ git filter-branch -f --env-filter "GIT_AUTHOR_NAME='hoge'; GIT_AUTHOR_EMAIL='[ID]+[username]@users.noreply.github.com'; GIT_COMMITTER_NAME='hoge'; GIT_COMMITTER_EMAIL='[ID]+[username]@users.noreply.github.com';" HEAD 

おわりに

めでたしめでたし
image.png

9
4
0

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
9
4