【トークンの設定】git pushができない
はじめに
git pushができなくなると、毎度調べての繰り返しになっているので備忘録。
エラーメッセージ内容
https://docs.github.com/ja/enterprise-cloud@latest/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-token git push origin main Username for 'https://github.com': <<USERNAME>> Password for 'https://<<USERNAME>>@github.com': remote: Support for password authentication was removed on August 13, 2021. remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication. fatal: Authentication failed for 'https://github.com/<<USERNAME>>/TIL.git/'
やったこと
- git pushをしようとしたところ、ユーザー名とパスワードの入力を求められる。
- githubのアカウントパスワードを入力しても認証が通らない。
- アクセストークンを作成するも、認証が通らない。
- アクセストークンを権限を設定した上で作成。 ←これで認証が通る
解決方法
公式ドキュメントを参照し、アクセストークンの設定を行う。
手順メモ
左側のサイドバーで [ Settings] をクリック。
左側のサイドバーの [ Personal access token] の下にある [Fine-grained トークン] をクリック。
[General new token] をクリック。 新しいトークンの生成を行う。
トークンの名前を入力。
トークンの有効期限を選択。 (30days, 60days, 90days, custome と選択できる)
[リソース所有者] で、リソース所有者を選択。 デフォルトでは、自分のgithubアカウントが設定されているので設定はこのままにしておいた。
[Repository access]でリポジトリの選択。 自分の場合は、個人開発用で使うだけなので[All repositories]を選択。
[Permissions] トークンに付与するアクセス許可を設定。
[Generate token] をクリック。
です。以上!