git エラー「error: src refspec master does not match any」が発生した場合の対処法

  • 作成日 2022.05.16
  • git
git エラー「error: src refspec master does not match any」が発生した場合の対処法

gitでエラー「error: src refspec master does not match any」が発生した場合の対処法を記述してます。

環境

  • git version 2.24.0.windows.2

エラー

push時に発生

git push -u origin master      

エラー全文

error: src refspec master does not match any
error: failed to push some refs to 'http://192.168.xxx.xxx/xxx/xxx.git'

原因

2020年10月以降から、「master」ブランチではなく、新規にレポジトリを作成すると「main」ブランチが作成されるため。
※下図は「gitlab」での画像

対処法

「main」にpushする

git push -u origin main