herokuのリモートの見つけ方

なかなかないと思うけど、herokuのリモートの名前を取得する方法がわからなくて困った。Githubからpullしてたからremoteが消えたんやろうか?

とりあえずメモっとく。

やり方

結論としては、こういう風にやればいい。

$ heroku login
$ heroku apps
=== My Apps
apps-citadel-2222
apps-twisted-weald-3333

これでアプリを名を確認して、リモートを追加する。

git remote add heroku git@heroku.com:apps-twisted-weald-3333.git
git push heroku master

結論を先に書いて、このあとはインストールや実行結果を絡めて書いておく。

詳細

heroku toolbeltをインストールしておく。

まずはherokuにログインする。

$ heroku login
Enter your Heroku credentials.
Email: example@example.com
Password (typing will be hidden): 
Authentication successful.

適当なやつは無いか探すためにheroku --helpを見る。

$ heroku --help
Usage: heroku COMMAND [--app APP] [command-specific-options]

Primary help topics, type "heroku help TOPIC" for more details:

  addons    #  manage addon resources
  apps      #  manage apps (create, destroy)
  auth      #  authentication (login, logout)
  config    #  manage app config vars
  domains   #  manage custom domains
  logs      #  display logs for an app
  ps        #  manage dynos (dynos, workers)
  releases  #  manage app releases
  run       #  run one-off commands (console, rake)
  sharing   #  manage collaborators on an app

Additional topics:

  certs        #  manage ssl endpoints for an app
  drains       #  display syslog drains for an app
  fork         #  clone an existing app
  git          #  manage git for apps
  help         #  list commands and display help
  keys         #  manage authentication keys
  labs         #  manage optional features
  maintenance  #  manage maintenance mode for an app
  members      #  manage membership in organization accounts
  orgs         #  manage organization accounts
  pg           #  manage heroku-postgresql databases
  pgbackups    #  manage backups of heroku postgresql databases
  plugins      #  manage plugins to the heroku gem
  regions      #  list available regions
  stack        #  manage the stack for an app
  status       #  check status of heroku platform
  twofactor    # 
  update       #  update the heroku client
  version      #  display version

heroku appsが自分の管理しているアプリを表示してくれそうなので、実行してみる

$ heroku apps
=== My Apps
apps-citadel-2222
apps-twisted-weald-3333

うまいこと表示された。
(herokuの命名ルールは知らないのでそれっぽい名前にしてる。名前はUltima Onlineから)

自分が設定したい名前がapps-twisted-weald-3333といことが分かったから、そこをremoteに追加する。

git remote add heroku git@heroku.com:apps-twisted-weald-3333.git

あとはpushするだけ。

$ git push heroku master
Fetching repository, done.
Counting objects: 20, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (15/15), done.
Writing objects: 100% (15/15), 2.28 KiB | 0 bytes/s, done.
Total 15 (delta 6), reused 0 (delta 0)

-----> Ruby app detected
-----> Compiling Ruby/Rack
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.6.3
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Fetching gem metadata from https://rubygems.org/..........
       Fetching additional metadata from https://rubygems.org/..
       Using rack 1.5.2
       Using eventmachine 1.0.3
       Using tilt 1.4.1
       Using daemons 1.1.9
       Using bundler 1.6.3
       Installing rack-protection 1.5.3
       Installing sinatra 1.4.5
       Installing thin 1.6.2
       Your bundle is complete!
       Gems in the groups development and test were not installed.
       It was installed into ./vendor/bundle
       Bundle completed (4.77s)
       Cleaning up the bundler cache.
       Removing thin (1.5.1)
       Removing bundler (1.3.2)
       Removing sinatra (1.1.0)

###### WARNING:
       You have not declared a Ruby version in your Gemfile.
       To set your Ruby version add this line to your Gemfile:
       ruby '2.0.0'
       # See https://devcenter.heroku.com/articles/ruby-versions for more information.

-----> Discovering process types
       Procfile declares types -> web
       Default types for Ruby  -> console, rake

-----> Compressing... done, 13.2MB
-----> Launching... done, v13
       http://apps-twisted-weald-3333.herokuapp.com/ deployed to Heroku

To git@heroku.com:apps-twisted-weald-3333.git
   ef0822f..213339b  master -> master

これでherokuにpushができて、LingrBotを動かすことができた。

追記2014/09/08
コマンドの修正
git remote add heroku git@githubheroku.com:apps-twisted-weald-3333.git

github.comじゃなくて、heroku.comだった。参考にしてできなかった人は申し訳ありません。