5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

GitHubでpushできない原因

Posted at

最近、久しぶりにGitHubで開発を始めたんだけど、何故かpushできない・・。
認証情報も合ってるはず!
結論から言うと、今回の原因は以下の2点でした。
・GitHubのデフォルトブランチがmaster → mainに変わった
・パスワード認証が廃止された

割と時間を取られたので、メモることにしました。

よくある原因

ネット上で検索するとよく出てくるのが、以下の原因。
・コミット忘れ
・競合
・ブランチ名間違い

今回は上記の原因では無かったが、エラーメッセージが被っていたので解決するのに時間がかかった。

GitHubのデフォルトブランチがmaster → mainに変わった

こちらは以下のエラーが出ます。(他の原因と被る)
タイトルの通り、master → mainに変えれば、プッシュできます!

% git push origin master
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/リポジトリ名/プロジェクト名.git'

パスワード認証が廃止された

こちらは見慣れないエラーが出たので、ググって直ぐに解決できました。
2021年8月13日からアクセストークンで認証するように変わったみたいです。
アクセストークンの作り方は、GitHub公式を参考に作成しました。

% git push origin main 
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でpushできない原因をまとめました。
長い間プライベートで開発していなかったので、そのツケですかね・・。
まだ長く続くてあろうIT人生を油断せず、日々、切磋琢磨していきます!

参考

https://qiita.com/shunsa10/items/e43564cf48f84b95455b
https://www.publickey1.jp/blog/20/githubmainmastermain.html
https://docs.github.com/ja/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token

5
1
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
5
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?