1
2

GitHubに空のリポジトリを登録後に初めてローカルからプッシュを行うときに上手くいかなかった際の解決方法

Posted at

現象

1.GitHubサイト上で空のリポジトリを作成した。

2.リモートリポジトリを追加した。

$ git remote add origin https://github.com/ユーザー名/○○○.git

3.上記で作成したリポジトリにpushを行ったが、エラーとなった。

$ git push origin <リポジトリ>
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/ユーザー名/○○○.git/'

解決策

1.ユーザー名とメールアドレスの設定を忘れていた。

$ git config --global user.name <ユーザー名>
$ git config --global user.email <メールアドレス>

2.もう一度pushを行ったがエラーとなった。

$ git push origin <リポジトリ>
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/ユーザー名/○○○.git/'

3.GitHubでアクセストークンを発行した。

  • GitHubのユーザーアイコンから設定を開く。
  • 左最下の開発者設定を開く。
  • 個人アクセストークンを開く。
  • repo/admin:repo_hook/delete_repoにチェックをいれてトークンを発行する。

02ae7188499a-20231109-2.png

  • 発行したトークをメモる。

4.プッシュに成功。

  • プッシュ時に問われるgithubのユーザー名とパスワードのうちパスワードは先ほど発行したトークを使用した。
1
2
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
1
2