Rails-Tutorial
rails-tutorialのherokuにデプロイするところで躓きました。
開発環境
AWS cloud9
実行したこと
ec2-user:~/environment/hello_app (master) $ heroku keys:add
? Which SSH key would you like to upload? /home/ec2-user/.ssh/id_rsa.pub
Uploading /home/ec2-user/.ssh/id_rsa.pub SSH key... done
ec2-user:~/environment/hello_app (master) $ heroku create
Creating app... done, ⬢ shrouded-beach-44231
https://shrouded-beach-44231.herokuapp.com/ | https://git.heroku.com/shrouded-beach-44231.git
ec2-user:~/environment/hello_app (master) $ git push heroku master
error: src refspec master does not match any.
error: failed to push some refs to 'https://git.heroku.com/frozen-citadel-28797.git'
rails-tutorialの手順通りに進めたつもりだったが
途中でSSH鍵間違えたり、heroku createを2回やったりでうまくいかなかった。
解決方法
・まず、herokuにログインして度重なるheroku createで作ってしまった不要なアプリを削除。
.新しく $ heroku create
・git remote -vでURLを確認したらぐちゃぐちゃだったので$ git remote set-url heroku <URL>
で住所変更。
・次に、git addもcommitもpushもしていないといけないことを知り、コマンド実行
1 $ git init
2 $ git add -A
例:送りたい荷物を決める
3$ git commit -m "first commit"
例:送りたい荷物の梱包
4$ git push -u origin master
例:荷物の発送
という感じでやってみました。
その後herokuをpush
$ git push heroku master
最後に $ heroku open
でデプロイできているか確認。
補足
heroku createの前に
$ heroku login --interactive
$ heroku keys:add
以上をする必要もあるみたいです。