【Heroku】Heroku の git push で refs が無い・・・

大した話ではないですが Heroku で試験的に Web アプリケーションをデプロイしようとした際に一瞬詰まった内容についてです。

git push heroku master

Heroku でのデプロイ手順は公式に以下の様に書かれています。(2021/03/07現在)

Deploy your changes

Make some changes to the code you just cloned and deploy them to Heroku using Git.

$ git add .

$ git commit -am “make it better"

$ git push heroku master

しかしこの通りにやると

error: src refspec master does not match any
error: failed to push some refs to 'https://git.heroku.com/hoge.git'

となります。

というのもお気づきかもしれませんが 2020/10 以降、新規にレポジトリを作成すると、master ではなく main としてブランチが作成されるので公式の手順にこの様に書いてありますが正しくは git push heroku main で push する必要があります。

まあ一番下に

You can now change your main deploy branch from “master" to “main" for both manual and automatic deploys, please follow the instructions here.

と main ブランチについて触れられてはいますがその上の手順では master のままなので脳死で手順コピペしてると今回みたいに一瞬止まってしまいます・・・

other入門

Posted by tsukasa