手順としては下記のようにやればよい。
Heroku にある Git リポジトリを楽に remote に設定する
- リモートリポジトリから
git clone
- heroku app作成
- herokuのリモートリポジトリも追加する
$ git remote add heroku git@heroku.com:APPNAME.git
または
$ heroku git:remote --app APPNAME
以降、push
したいときは以下のようにする。
$ git push heroku master
$ git push origin master
ここで、個人的に間違った手順でいままでやっていたことに気づく…
やらかしたこと:
- リモートリポジトリから
git clone
- ローカルリポジトリで
.git
以下を消去して -
git init
してherokuにpush
してた
なので、herokuともう一個別のリモートリポジトリも使うための方法を探ったら以下のようになった。ちなみにリモートリポジトリがbitucketの場合。
$ git remote add origin git@bitbucket.org:YOUR_ACCOUNT/REPOSITORY.git
参考
ローカルの既存のgitリポジトリをbitbucketに放り込む方法
git remote 使い方
リモートのリポジトリを変更したい場合
リモートのリポジトリ名を変更したい場合(そんなケースある?)は下記のとおりに。
$ git remote
hoge
origin
# リモートリポジトリ hoge から fuga に変更
$ git remote rename hoge fuga
$ git remote
fuga
origin
リポジトリ名はそのままにしたくてリポジトリのURLを変更したい場合は、結局よくわからなくて一旦削除してから追加したらできた。(もっといいやりかたあったら教えてください…)
$ git remote -v
hoge git@hoge.com:hoge.git (fetch)
hoge git@hoge.com:hoge.git (push)
origin git@abc.org:xyz/hoge.git (fetch)
origin git@abc.org:xyz/hoge.git (push)
# リモートリポジトリを一旦削除して、fuga.git を追加
$ git remote rm hoge
$ git remote add hoge git@hoge.com:fuga.git
$ git remote -v
hoge git@hoge.com:fuga.git (fetch)
hoge git@hoge.com:fuga.git (push)
origin git@abc.org:xyz/hoge.git (fetch)
origin git@abc.org:xyz/hoge.git (push)