Greyed out Github folder and URL change

Deploy to Github

As part of the process of deploying my offline Flask app to Heroku, I also deployed it to Github.

Currently I know how to push updates to GitHub, create new repositories and link them to my local folders. This is what my process looks like. Bear in mind that there is a lot more I need to learn about GitHub.

To initialise the local folder on your laptop, run the following command in your terminal or command line:

git init

To link this folder to a Github repository run:

git remote add origin https://github.com/      (this is followed by the specific path to your Github repository)

e.g.

git remote add origin https://github.com/denisddesigner/python_mentor

 

Push an update from local folder to Github repository:

  1. git add .
  2. git commit -m "your comment here"
  3. git push origin master

Sometimes I run into merge errors. If I cannot resolve the merge issues via a pull request then I sometimes force the push command. may not be the ideal solution but it keeps up the momentum.

git push -f origin <branch>

Greyed out Folder on GitHub

During the process of deploying my Flask app to GitHub I ran into a new error. The folder appeared in Github but it was greyed out, so I couldn't move inside the folder. There was no issues with the folder locally. I had to do quite a bit of searching to find a solution that worked for me. Here is an explanation of the solution I found.

Update Flask Online URL's

Once I had gotten past these few hiccups on GitHub. I deployed to Heroku with the git command:

git push heroku master

 

It was a little confusing to me as to how git knows where to push to and what heroku master is. Here is a brief answer to this question. The confusion stemmed from the fact that I was tended to associate Git with GitHub so I couldn't as clearly see how Git could know how to push to a Heroku repository.

Flask App Online

Once the Flask App was online I realised that the URL's needed to be changed. The URL's in my Flask Portfolio were using the local host URL's and now the app needed the URL's for the web.

I first decided to change the default name of the app. The below image shows where you can update this in Heroku.

Next I updated the URL's locally to reflect the online URL. This mean't changing the URL's from

http://127.0.0.1:5000/python_apps

to

https://denisflask.herokuapp.com/python_apps

Thankfully the use of inheritance within the Jinja2 templating system means that there aren't that many places where the URL needs to be changed.

When I went to push the URL updates to Heroku it was still using the old online URL. In order to rectify this I ran the following commands:

git remote rm heroku

$ heroku git: remote -a newname

My last step was to create a copy of the Flask app. I use this copy as a local version of the website. In this version I use the localhost URL's. When I am happy I make the changes to the online version of my Flask app on my MacBook which I then use to update the online app on Heroku.

 

Did you find this blog post useful? Is there something you don’t understand or something I have omitted? If so I would love to hear from you in the comments section below or by dropping me an e-mail.