0
1

More than 1 year has passed since last update.

【Git】pushしたら『error: src refspec master does not match any』が発生

Posted at

事例

・git hubにてリモートリポジトリ作成済み。
・ローカル環境でgit addgit commit等使用しながらバージョン管理。
・一通り完了したのでgit push origin masterを実行したところ下記エラーが発生。

% git push origin master
error: src refspec master does not match any
error: failed to push some refs to 'リポジトリパス'

解決法

git push origin masterを下記に変更

git push origin main

原因

・以前は「master」ブランチが自動作成されていたが、2020/10以降新規レポジトリを作成すると「main」ブランチが作成されるため。

→作成しているレポジトリがgit push origin masterなのか、git push origin mainなのか気をつける必要あり。

ところで「ブランチ」とは

履歴の流れを分岐して記録していくための機能。
この機能を使うことで、他のメンバーと分担して作業を行うことができ、合流(マージ)することで1つのブランチにまとめることができる。

今回の「masterブランチ」について
・最初のコミットで生成されるブランチで、要するに主軸となるブランチ。
・個人で開発している場合など、ブランチを分岐させない場合、masterに対してpushすることになる。
※この名称が2021/10以降「main」に変更

参考

git push時のerror: src refspec master does not match anyについて
サル先生のGit入門

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