0
2

More than 1 year has passed since last update.

初回git push 時の「src refspec master does not match any」解決法

Posted at

エラー内容

新規アプリを作成し、pushした際に以下のエラーが出力された。

$ git push
error: src refspec master does not match any
error: failed to push some refs to 'github.com:xxx/xxx.git'

2行目が赤文字になっていたため、2行目を中心に調べていると、
- pullしてからmerge
- git pull --rebase

という解決策が出てくる。
これはリモートとローカルでコミットが分かれていて、マージできなくてrejectedされている状態の時のエラーの解決法である。
確かにこのエラーでも
「error: failed to push some refs to 'github.com:xxx/xxx.git'」というエラーが出力されるため、2行目のエラー内容で調べると違うエラーの解決策にヒットしてしまう。

解決策

1行目の「error: src refspec master does not match any」で調べてみる。

$ git push origin main

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

参考

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