如何将我的回购附加到 heroku 应用程序

我创建了一个 heroku 应用程序,然后我的机器就崩溃了。我有一台新机器。如何将我现有的应用程序连接到 heroku 应用程序。当我访问 heroku 页面,我的应用程序的网址是这样的

git@heroku.com:myapp.git

我不能克隆这个应用程序,因为我已经有了来自 github 的 myapp。因此,我需要添加 heroku 作为远程到我现有的 github 应用程序。任何人都知道语法。

46991 次浏览

If you've heroku toolbelt:

If you're using the Heroku Toolbelt, the newer syntax is

heroku git:remote -a project

See this for more.

Credits: user101289's solution

Else if you don't have heroku toolbelt:

First do this:

git remote add heroku git@heroku.com:{heroku-app-name}.git

Then do this:

git push heroku master
heroku open

If you're using the Heroku Toolbelt, the newer syntax is

heroku git:remote -a project

See this for more.

If you're using just Git without installing the Heroku Toolbelt, you can also create a new application.

Login to your account and go to this link

https://dashboard.heroku.com/apps

Look at the plus sign on the top right corner then select

Create new app

Leave the application name blank to let heroku choose one for you. Let say your heroku app name is new-app-xxxxx, so to test on adding a file in to it you may try the following command:

git clone https://git.heroku.com/<new-app-xxxxx>.git
cd <new-app-xxxxx>
echo "my test file" > test.txt
git add .
git commit . -m "my test on commit"
git push

Put empty (blank) when the Git prompt for username, and your API Key for the password. You can get your API Key by showing it from the link below.

https://dashboard.heroku.com/account

Note: You cannot authenticate with the Heroku HTTP Git endpoint using your Heroku username (email) and password. Use an API key as described here.