How to attach my repo to heroku app

Heroku

Heroku Problem Overview


I create a heroku app and then my machine crashed. I have a new machine. How do I attach my existing app to heroku app. When I visit heroku page the url for my app is like this

git@heroku.com:myapp.git

I can't do clone this app because I already have myapp from github. So I need to add heroku as remote to my existing github app. Anyone knows the syntax.

Heroku Solutions


Solution 1 - Heroku

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

Solution 2 - Heroku

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

heroku git:remote -a project

See this for more.

Solution 3 - Heroku

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNick VanderbiltView Question on Stackoverflow
Solution 1 - HerokuthenengahView Answer on Stackoverflow
Solution 2 - Herokuuser101289View Answer on Stackoverflow
Solution 3 - HerokueQ19View Answer on Stackoverflow