0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

GitHubのメールアドレスを消す前に知っておきたい「草が消える」話

0
Last updated at Posted at 2026-07-07

転職や会社ドメインの変更、学校メールの利用終了などを機に、GitHub アカウントから古いメールアドレスを削除したとする。すると、そのメールで作った過去の commit が「自分の貢献」ではなくなる。プロフィールの草(contribution graph)が減り、リポジトリの Contributors グラフの commit 数も減る。

3行でまとめ

  • GitHub は「commit の author email」と「アカウント登録メール」の一致で貢献を紐づけている
  • だから登録メールを削除すると、そのメールで作った過去 commit の帰属がまとめて外れる
  • 対策は 2 つ。今後は ID 付き noreply で commit する。メールを削除する前に過去 commit の author email を確認する

なぜ消えるのか

Git の commit には、author email が記録されている。

git log -1 --format='%an <%ae>'

GitHub は、この author email がアカウントに登録されているかどうかで、commit をアカウントに紐づける。仕組みはそれだけだ。

commit author email = you@old-work.example
account email       = you@old-work.example
result              = attributed

アカウントから you@old-work.example を削除すると、この対応が切れる。

commit author email = you@old-work.example
account email       = not registered
result              = unattributed

過去 commit に使ったメールアドレスを削除するか、別アカウントへ移すと、その contribution は表示されなくなる。これは公式ドキュメントにも明記されている(Troubleshooting missing contributions)。

草だけでなく Contributors グラフも減る

影響は 2 か所に出る。ただし、減り方が違う。

リポジトリの Contributors グラフ プロフィールの草
集計対象 commit のみ commit に加えて Issue・PR・review など
メール削除の影響 commit 数が直接減る commit 由来の分だけ減る

Issue や PR は、メールではなく GitHub アカウントの操作として記録される。だから、メールを削除しても残る。「Contributors の commit 数は減ったのに、草はあまり変わらない」ように見えるのは、このためだ。

対策 1: 今後の commit は ID 付き noreply にする

GitHub が提供する noreply email を使う。こうすれば、仕事用メールや学校メールが使えなくなっても、commit の帰属は影響を受けない。

YOUR-ID+YOUR-USERNAME@users.noreply.github.com

古い username-only 形式(YOUR-USERNAME@users.noreply.github.com)は、username を変更すると紐づきが切れる。ID 付きの形式を使う。

手順は 2 つ。

  1. GitHub の Settings → Emails で Keep my email addresses private を有効にし、表示される noreply email をコピーする
  2. Git に設定する
git config --global user.email "YOUR-ID+YOUR-USERNAME@users.noreply.github.com"

repository local の user.email は global より優先される。古い仕事用メールが個別設定で残っていないか、あわせて確認する。

git config user.email          # このリポジトリで実際に使われる値
git config --unset user.email  # local 設定を外して global に寄せる

対策 2: メールを削除する前に過去 commit を確認する

削除しようとしているメールで commit していないか、先に確認する。

git log --format='%ae' | sort -u

削除予定のメールアドレスがここに出てきたら、削除した時点でその commit の帰属は外れる。別の GitHub アカウントにメールを移した場合も同様だ。

すでに消えた分は、当時のメールを再追加すれば戻る

当時の author email を GitHub アカウントに再追加する。それだけで帰属は戻る。そのメールボックスにアクセスできる必要はない。反映には最大 24 時間かかる。それでも戻らなければ、GitHub Support に問い合わせる。

特定の commit の author email は、commit URL の末尾に .patch を付ければ確認できる。

参考資料

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?