herokuのアプリ名を変更する際に、上の画像のように、herokuのダッシュボードから変更しようとすると、Warningが出て、「変更後はremotesも変更が必要」と言われるので、手動で変更してやらないといけません。その方法でも可能ではありますが、herokuのコマンドで $ heroku apps:rename ~ を使えば、アプリ名とGitリモートurlも一発で変更してくれます。
まずはpush先となるリモートのurlの確認です。ここのリモートurlが通っていなければ、 $ git push heroku master のコマンドが通らないことになります。
1 2 3 |
$ git remote -v heroku https://git.heroku.com/old-name.git (fetch) heroku https://git.heroku.com/old-name.git (push) |
そして、変更したい新しいアプリ名をつけて $ heroku apps:rename ~ のコマンドを打つとこのようなメッセージが出て、gitリモートも変更されます。
1 2 3 4 |
$ heroku apps:rename new-name Renaming remonote to new-name... done https://new-name.herokuapp.com/ | https://git.heroku.com/new-name.git Git remote heroku updated |
変更されているのが確認できます。
1 2 3 |
$ git remote -v heroku https://git.heroku.com/new-name.git (fetch) heroku https://git.heroku.com/new-name.git (push) |
herokuのダッシュボードからも変更されているのが確認でき、https://new-name.herokuapp.comでアクセスできるようになります。
簡単ですが以上です!ご覧いただき、ありがとうございました!!😌