GitHubでAuthentication failedが出てpushできなくなった

自分の頭の中を整理するために初ブログを書いてみようと思います💦
誰かの参考になれば幸いです。

git pushでエラーが出た

❯ git push origin master                                       
Username for 'https://github.com': 
Password for 'https://*****@github.com': 
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/*****/*****.git/'

GitHubでは2021年8月13日にパスワード認証が廃止されていました。。 github.blog

調べてみるとprivate access tokenを作り直すといいらしい。 以下のドキュメントを参考に取得。 docs.github.com

再度push!あれ...(さっきのはできたのだろうか...)

❯ git push origin master
Username for 'https://github.com': 
Password for 'https://*****@github.com': 
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 https://github.com/*****/*****.git
 ! [remote rejected] master -> master (push declined due to email privacy restrictions)
error: failed to push some refs to 'https://github.com/*****/*****.git'

push すると private のメールアドレスが公開されちゃうけど良いの?的なメッセージが...

ssh keyは登録しているし、通信プロトコルはgit。

❯ git remote -v
origin  https://github.com/*****/*****.git (fetch)
origin  https://github.com/*****/*****.git (push)

GitHubへのアクセスは通るのか実行。

❯ ssh -T git@github.com
Hi *****! You've successfully authenticated, but GitHub does not provide shell access.

他は問題なさそう...

現在のメールアドレス設定を確認後、ダミーのアドレスに設定

❯ git config --global user.email *****+*****@users.noreply.github.com 

一旦 commit を取り消す。

メールアドレスは commit 時に記録されているよう。(このまま再push しても同じエラーが出る。)
ワークディレクトリの内容はそのままでコミットだけを取り消します。

❯ git reset --soft HEAD~ 

再度commit→pushで問題なくできた。

git logのメールアドレスもちゃんと変わっていました。