DEV Community

Nkwam Philip
Nkwam Philip

Posted on

Hassles pushing a deployed heroku app to my github repository and re-deploying to heroku.

Just so you don’t spend over 3 hours trying to push a web app to heroku after pushing it to your GitHub repo. Here I’d be showing you practically how to push your web app to heroku, change the branch and push the same code to your GitHub repository.

I had just deployed a flask CRUD app to heroku, https://flaskcrudmanagerapp.herokuapp.com/
Image description


And the master branch was heroku.

Image description

I made several commit changes afterwards, pretty much to show it’s a working app I pushed into production and have modified multiple times.

Image description

But I just thought to have my web app in my GitHub repository, at least. So I had to create a new GitHub repository, then I added a new origin to the main branch. Meanwhile I had checked the list of remote repo links. You can see clearly in the picture above that I have heroku and an origin alongside.

Image description

Most importantly, origin was push as the MAIN Branch. Literally where the problem unknowingly started.

Image description

Then i tried pushing a change to my deployed heroku app, but whoossh, it stopped working.

Image description

I removed the origin and main branch having the github repo i made earlier, tried pushing my heroku app again, but it still didnt work. It got hilarious at a point, yo i just removed the dude that got me into the problem.
Image description
it did tell me there was no match for master.

i had to remove heroku, sadly i thought i was in a messier situation but i luckily added it back. Tried pushing again but naahh, it didnt work.
Image description
i used "Get-url", staged with force (--force, -f) but it still didnt work. Could have actually given up buh nope, i eventually figured it out hereeee, i pulled the branch and pushed with force, lol.

Image description

I believe you've seen the solution already. it happened that there was no branch (since i deleted the remote - main branch for the github repo i created earlier) and i have to push heroku as the main branch --The Upstream.

One common cause of this behavior is attempting to deploy code from a different branch, in-fact the branch wasn't existinggg.

Image description

Finally i set Heroku as the upstream main branch and voila, i can now push my commit changes to my live app. My dear Flask Application.

Image description

Yeah, that reminds me, i have to remove the staging app i force created earlier.

I trust you had a great read here.

Top comments (0)