Herokuにデプロイする

先ずGit
$ git init
$ git add .
$ git commit -m "first commit"

$ heroku create AppName
$ git push heroku master

$ heroku logs
$ heroku apps:rename newname (--app oldname)
$ heroku stack --app AppName

                                                                                • -

$ heroku login/out

$ heroku accounts:add my_account
Enter your Heroku credentials.
Email: my_email
Password (typing will be hidden):

Add the following to your ~/.ssh/config

Host heroku.my_account
HostName heroku.com
IdentityFile /PATH/TO/PRIVATE/KEY ==>> ~/.ssh/id_rsa.my_key
IdentitiesOnly yes
$ heroku accounts:set my_account


$ heroku keys -l
=== someones's_account Keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAA...0GCb2s+Wca someone's_key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAA...Ihr1cfXzVh otherone's_key
$ heroku keys:remove someone's_key (or "AAAAB3NzaC1yc2EAAAADAQABAA...0GCb2s+Wca")
$ heroku keys -l
=== someones's_account Keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAA...Ihr1cfXzVh otherone's_key



$ heroku keys:add
Found the following SSH public keys:
1) id_rsa.my_key.pub
2) id_rsa.other_key.pub
3) id_rsa.pub
Which would you like to use with your Heroku account? 1
Uploading SSH public key /home/me/.ssh/id_rsa.my_key.pub... done


$ heroku ccounts
 my_accoun
 *other_accountt
 
$ heroku accounts:set my_account
 *my_account
 other_account

$ heroku apps
=== My Apps
OtherName
AppName


リモート変更
$ git remote -v
heroku git@heroku.com:OtherName.git (fetch)
heroku git@heroku.com:OtherName.git (push)
origin https://my_account@bitbucket.org/my_group/sinatra_example (fetch)
origin https://my_account@bitbucket.org/my_group/sinatra_example (push)


$ git remote rm heroku
$ git remote add heroku git@heroku.com:AppName.git
$ git remote -v
heroku git@heroku.com:AppName.git (fetch)
heroku git@heroku.com:AppNamea.git (push)
origin https://my_account@bitbucket.org/my_group/sinatra_example (fetch)
origin https://my_account@bitbucket.org/my_group/sinatra_example (push)


いちいちリポジトリの URI を打ち込むのは面倒な場合は
$ heroku apps --account <手元のアカウント名>
=== My Apps
my_app
other_app

$ heroku git:remote --app my_app
Git remote heroku added

また,Heroku からまず第一に clone するのであれば,
heroku git:clone my_app

ヘルプ
heroku help git
heroku help git:remote
heroku help git:clone



git push heroku master

                                                                • -

http://d.hatena.ne.jp/Syunpei/20111202/1322806676

アプリケーション名前変更はサイトの管理画面から「Rename」ボタンを押します。

ただそれだけだと、ローカルのherokuリポジトリをpushするときに、いつものgit push heroku masterが通じなくなってしまう。「heroku」に紐づいたリモートリポジトリの名前が変わってしまったから。また、herokuコマンドもエラーになるようになってしまう。なので、以下のコマンドを実行してローカルの状態も変更しておく。

$ heroku rename newname
http://newname.heroku.com/ | git@heroku.com:newname.git
Git remote heroku updated

ただ、上のコマンドだとリモートリポジトリからのチェックアウトが自動的に行われてしまうらしい(未確認)。なので、チェックアウトなしでリネームするには以下。

$ heroku rename newname --app oldname
http://newname.heroku.com/ | git@heroku.com:newname.git

で、gitで使用するリモートリポジトリ「heroku」のURLも変更しておく。

$ git remote rm heroku
$ git remote add heroku git@heroku.com:newname.git

                                                                                              • -

$ git push heroku master
The authenticity of host 'heroku.com (50.19.85.154)' can't be established.
RSA key fingerprint is 8b:48:5e:67:0e:c9:16:47:32:f2:87:0c:1f:c8:60:ad.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'heroku.com,50.19.85.154' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: The remote end hung up unexpectedly

      • >

heroku keys:add ~/.ssh/id_rsa.pub

                                                      • -

http://d.hatena.ne.jp/EnnuimaZ/20120407/1333806290
https://gist.github.com/konitter/5370904