DEV Community

Cover image for How to Fix that Heroku Push Error!
Emma Odia
Emma Odia

Posted on

How to Fix that Heroku Push Error!

You made a mistake pushing your code to the work account instead of your personal account!?!! The Horror! The Pain!! OMG... The PAIN!!!

Apparently you were on your PC and had logged into the work account the last time you made a push and now you have created a personal heroku app, most likely a weekend hobby project and yes, you pushed to the office dashboard... Hmmm. Well let's fix that shall we?

Here's how to fix that.

  1. Log in to your account on Heroku via the CLI
heroku login
Enter fullscreen mode Exit fullscreen mode

Enter your credentials. Apparently this is why you pushed to the wrong account in the first place! Duh!

  1. Check the remote urls that your app is hosted on
// Check for the current url 
git remote -v
Enter fullscreen mode Exit fullscreen mode
  1. Well seeing as your current user account cannot push to the remote heroku url, we then have to delete it!
// remove remote url
git remote rm heroku
Enter fullscreen mode Exit fullscreen mode
  1. Now we have to create a new Heroku app via the CLI since we are now logged into your user account
heroku create
Enter fullscreen mode Exit fullscreen mode
  1. You get a url at this point, which is also created on your heroku dashboard. Now set this url as the remote url for your app
git remote add https://git.heroku.com/<unique-heroku-app-name>.git
Enter fullscreen mode Exit fullscreen mode
  1. We can never be too careful! Just to be sure run
git remote -v
Enter fullscreen mode Exit fullscreen mode
  1. Now we are confident to push our app to heroku
git push heroku master
Enter fullscreen mode Exit fullscreen mode

Phew! That was a close call mate!

Top comments (0)