Hassles pushing a deployed heroku app to my github repository and re-deploying to heroku.
Tags: webdev, programming, github, heroku
Published: 2022-05-24 23:46:11


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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1p1by51pnh90oe2csk1l.png)

￼
And the master branch was heroku.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w0d6usn79mtnul6m9sxf.png)
￼
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4cicrkgeqmprl0pbev5e.png)
￼

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/55e9li0g98mca3cgpixg.png) 
￼
Most importantly, origin was push as the MAIN Branch. Literally where the problem unknowingly started.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6h07bolqtkqigon5agji.png)

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3rk4p1p67nmq0ll1oedx.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9c4incju7k5ocwsv6uce.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ylrq5vbeotu4qgwsjik7.png)
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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zjw77ga1xvck3ul15rht.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k7lfkyvgtnuuf21jr8n1.png)

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3wcgl1r7rdoqhza28t0y.png)

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

I trust you had a great read here.