How to attach my repo to heroku app - heroku

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.

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.

Related

"Couldn't find that app." when running heroku commands in console

I'm trying to run commands for my heroku app in my console, but it keeps telling me "Couldn't find that app." even though when I run heroku apps in my console it tells me I have one app called worldofwarcraft-api
So heroku recognizes my app in the apps list, but I can't run any commands to access it. The line I want to run is
heroku ps:scale web=1 --app worldofwarcraft-api
I'm trying to troubleshoot why my API returns a 503 when I try to make a GET request to it. This is the fix the heroku faq told me to try, but it's just telling me it can't find my app.
I'm wondering if it has something to do with the fact that I deployed my API from github, rather than running the heroku setup in my console. I don't know if that would effect my ability to run heroku commands on the app in my local console.
Apologies if my formatting is off a bit. I'm still getting used to this site.
In my case, someone renamed GitHub repo and I tried to find Heroku app with new GitHub name
It helps me
heroku apps
heroku git:remote -a YOUR_APP
Solved it. Just sharing for future searches.
The issue was fixed by running git init and then heroku git:remote -a worldofwarcraft-api in my command line while inside my repositories folder. This initialized git in the repo and then set the heroku git remote to that repository.
Hopefully, this helps anyone else who had a similar issue.
Just an easy way to solve this issue:
1st: Add the command into your terminal: $ heroku apps
If you already logged into your heroku account from your terminal, all your apps will appear as a list like this:
your-project-name-1
your-project-name-2
your-project-name-3
your-project-name-4
2nd: Then chose which one you are needing to connect with the following command:
$ heroku git:remote -a your-project-name-2
If you've done the connection properly you'll receive the following output:
set git remote heroku to https://git.heroku.com/your-project-name-2.git
For my case, I was renaming my github repository.
You can find it in your repository settings then just rename it, it appears in the first place.
Then you can continue with git init again to re-initiate your existing git repository and then set your heroku remote with your heroku apps new name heroku git:remote -a YOUR_APP_NAME
If the app belongs to a team that you participate in, you have to specify the team option in the commands to see the app:
E.g:
heroku apps -t <team name>
or
heroku ps:scale web=1 --app worldofwarcraft-api -t <team name>

Don't have access to Heroku app

I have a mystery app in Heroku. It's called weird-app-5536
When I try to push my code to Heroku I get this message:
Your account my_email#geemail.com does not have access to weird-app-5536.
!
! SSH Key Fingerprint: *************************************************
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
When I try...
heroku apps
I get a list of my apps, but it does not include the mystery app, weird-app-5536.
I can't destroy or rename the weird-app-5536 app. It always says I don't have access.
The app does not appear on my list of apps on the Heroku website.
When I type
git remote -v
I get this:
heroku git#heroku.com:weird-app-5536.git (fetch)
heroku git#heroku.com:weird-app-5536.git (push)
origin git#github.com:thisisme/my_code.git (fetch)
origin git#github.com:thisisme/my_code.git (push)
I deleted my old ssh keys. I created a new one and added it to Heroku
I can create new apps and they show up on my list of apps.
As far as I know I only have one Heroku account.
Stumped. I don't know where to go from here.
What's happened is the git repo on which you're working is tied to an old remote. No need to contact heroku or anything... Just remove the heroku git remote and readd it.
Remove by running:
git remote rm heroku
Readd with:
heroku git:remote -a appname
More here: https://devcenter.heroku.com/articles/git
Honestly, I would try to get a hold of Heroku support. It might be possible that you were listed as a contributor to another app by someone but weren't given write access? Heroku support is probably your best bet.

Setting up an existing Heroku application on a new machine

I've an existing project that works fine on another machine, but I've just upgraded and from within the project development directory, everytime I run a heroku command I have to post-fix it with --app
I feel like I've missed an application setup stage, but I can't figure out what, as everytime it states:
Run this command from an app folder or specify which app to use with --app APP.
Help appreciated.
You can solve this by adding the Heroku app to your .git/config folder.
If you are in the root of your project, run the following command:
git remote add heroku git#heroku.com:appname.git
This will set a line in your .git/config file which the heroku command line tool uses to figure out what app you're using :)
In other words, your local repo doesn't have Heroku app URL configured against an app name
Similarly what we do with git remote add ( we pass git URL as a destination for push/pulling of code )
that how our git know which repo/URL to hit (push/pull from )
Heroku also follows the same method/process.
All you have to do is add Heroku app URL (so that ur Heroku command have a reference for app URL )
it will know against which URL you are running your command against
To confirm if remote named Heroku has been set for your app:
git remote -v
if not configured or if you want it for an existing app
heroku git:remote -a app_name
it's a way to link your folder to the Heroku app
The Heroku recommended way:
heroku git:remote -a my-heroku-app-id -r what-i-want-to-call-it
Source: https://devcenter.heroku.com/articles/git
Run this command from an app folder or specify which app to use with --app APP
The other answers address the first part of that statement, it is perfectly acceptable to run heroku commands in any directory. For example I have a customer facing front end project /front-end and a rails based /back-end project. I often work in the /front-end directory and if I have to connect to the production database I'll run heroku run rails c -a back-end. After I exit irb then I'm back in my desired directory.

Update an existing app

I have a Django-cms website running online on Heroku. I pushed this online from a device at work. Now I'm at home and I have same project running on my machine and I did some changes and I wanna push them live on the same link.
What I need to do?
git init
git add .
heroku create
that gonna create an other link , but I wanna push my amends on the same link I have already.
Any idea?
You need to get add the Heroku git remote to your new application. Grab the app's git repo from the apps page in Dashboard and then do;
git remote add heroku <git repo here>
and then you'll be able to push as you are able to on the other machine.
ok I didn't add my public key I did:
heroku keys:add ~/.ssh/id_rsa.pub
and it worked! :)

How can I pull an existing heroku app to new location for development?

I currently have the latest version of my code on another computer that I want to develop from (Home computer and laptop for when I'm out and about) I set up heroku for my app on my laptop. Now I need to associate my code on my desktop so that I can push to heroku from there as well.
This is what I get from my desktop:
desktop:~/NetBeansProjects/onlinescheduler$ git pull heroku master
fatal: 'heroku' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
I can't do heroku create because that will create a separate app. How do I associated the existing code with (or pull down a brand new version from) heroku?
Whats the command to do this?
Also, If you've never used heroku before on the other machine, you'll need to do a few more things first:
$ gem install heroku
$ heroku login
[then enter your credentials]
$ heroku keys:add [path to keyfile]
Now you can clone the remote repository:
$ git clone git#heroku.com:<heroku_app>.git <local_directory>
First of all, you'll want to follow the Quick Start instructions for Heroku, which you can get straight from the horse's mouth, right here: https://devcenter.heroku.com/articles/quickstart
Once you've gotten through step 3, come back here.
Then, you can type this into the command line:
heroku git:clone -a myapp
This is described here:
https://devcenter.heroku.com/articles/git-clone-heroku-app
Then, if you want to grab the database too, here are some options.
Newer Heroku instructions on import/export:
https://devcenter.heroku.com/articles/heroku-postgres-import-export
Older heroku instructions on push and pull: https://blog.heroku.com/archives/2009/3/18/push_and_pull_databases_to_and_from_heroku
If you are using mongo, this is a useful tool to sync your mongo database: https://github.com/pedro/heroku-mongo-sync#readme
If you first need to get the app from Heroku, clone your app.
To do that, write in your Terminal:
heroku git:clone -a your_app_name
If you already have the app and the remote to heroku follow the next steps. If not, you can check instructions here https://devcenter.heroku.com/articles/git
Find the name of your database
Write in your Terminal:
heroku pg:info -a your_app_name
it will look something like this:
HEROKU_POSTGRESQL_MAROON_URL
Find the name of your local database
In your Rails app go to config/database.yml
it will look something like this:
your_app_name_development
Clone your production database (PostgreSQL)
Write in your Terminal with your own database names:
heroku pg:pull HEROKU_POSTGRESQL_MAROON_URL your_app_name_development -a your_app_name
HEROKU_POSTGRESQL_MAROON_URL is an example of how could be the name of your production database (in Heroku):
my_app_name_development is the name of your development database (locally)
the_name_of_my_app is the name of your app in Heroku
Don't forget to finish this with bundle install...
If you already have your code base ready and have heroku setup, use:
$ heroku git:remote -a your_heroku_app
This will allow you to deploy from your new location.
Reference: https://devcenter.heroku.com/articles/git#creating-a-heroku-remote
Once you create a key in a new computer, you have to upload your new SSH key by typing heroku keys:add.

Resources