Setup:
I have a Node.js (MEAN fullstack) application (ie. myApp) deployed on heroku that works fine. I deploy with standard git push
$ git push heroku master
I wanted to create a staging replica of the application and used heroku fork to do so (as per https://devcenter.heroku.com/articles/fork-app) .
$ heroku fork -a myApp myApp-staging
The staging application also works fine with its' own database and has its' own set of config variables (es expected). !!! IMPORTANT
I also created a new git remote
$ git remote add staging [email protected]:myApp-staging.git
// repo address taken from "heroku info -a myApp-staging"
Problem:
1) If I try to push to production ie. "git push heroku master" it works fine.
2) If I try to push to staging
$ git push staging master
I get "Permission denied (publickey)."
3) If I try to clone my staging application git repo to another directory I get an empty repo
$ heroku git:clone -a industryhub-staging
// warning: You appear to have cloned an empty repository
Where is my staging repo? Which code is Heroku running on my staging instance? An finally - how do I push to staging?
Figured it out. Here for posterity.
The error was the wrong remote for the staging app. I created it with
$ git remote add staging [email protected]:myApp-staging.git
and I had
$ git remote -v
heroku https://git.heroku.com/myApp.git (fetch)
heroku https://git.heroku.com/myApp.git (push)
staging [email protected]:myApp-staging.git (fetch) // wrong
staging [email protected]:myApp-staging.git (push) // wrong
I should have done
$ git remote add staging https://git.heroku.com/myApp-staging.git // over https
Now my git shows
$ git remote -v
heroku https://git.heroku.com/myApp.git (fetch)
heroku https://git.heroku.com/myApp.git (push)
staging https://git.heroku.com/myApp-staging.git (fetch) // OK
staging https://git.heroku.com/myApp-staging.git (push) // OK
And the life is peachy again!
Note: Heroku says that the new repo IS EMPTY after forking an app. https://devcenter.heroku.com/articles/fork-app#forked-app-state
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With