Error: src refspec master Git

Error src refspec master does not match any (Git)

Gitでremoteにpushしようとすると、"Error src refspec master does not match any"というエラーが出る場合があります。

Shou Arisaka
1 分で読める
2021年4月16日

Gitでremoteにpushしようとすると、“Error: src refspec master does not match any”というエラーが出る場合があります。

> git push heroku master
error: src refspec master does not match any
error: failed to push some refs to 'https://git.heroku.com/salty-eyrie-89059.git'

Image

多くの原因として、一番最初に確かめておきたいのは、リファレンスが本当に存在するかどうか、です。 git show-refを実行してリファレンスをリストします。

> git show-ref
e4cd18c39bd6cfc5f6176b5adbe2ae5238d4776f refs/remotes/origin/HEAD
e4cd18c39bd6cfc5f6176b5adbe2ae5238d4776f refs/remotes/origin/main

Githubは最近メインのブランチを”master”から”main”へ変更する仕様変更がありました。今回のエラーの原因はここにあったようです。

push先をmasterからmainへ変更して再度実行すると、上手くいきます。

git push heroku main

(参考)

Message ‘src refspec master does not match any’ when pushing commits in Git - Stack Overflow

この記事をシェア

Shou Arisaka 2021年4月16日

🔗 リンクをコピー