I felt like I totally understood when I set up my git config for an app running on heroku to finally have a staging and production environment separately. However, it has been a few months since I did it, and now things are not working as I thought they would. Clearly, I did not understand at all.
Essentially, I wanted to have a heroku staging app (generic heroku url) and my heroku production app (at my url) where I can get logs for both and manage both through the heroku CLI on my terminal. This seems like a fairly typical need, and I expect I'm not alone in getting confused.
Here's where I'm at:
- I followed Heroku dev guidance to setup my environment... I think
- Everything was working smashingly. My master pushes went to my github repo and were automatically deployed on my production heroku app. My staging pushes went directly to my heroku staging app.
- I was concerned about an issue and ran
heroku logsand then a series of heroku commands on my master branch only to continuously get information about my staging environment. No amount of
heroku logs -r productionwould change this situation.
- In an attempt to get logs from my production app, I ran
heroku git:remote -a appname -r production. Sadly, that changed my production pointer from my github repo back to heroku (which expected to get code from github).
- I manually changed the
urlfor my production remote back to github in my git.config. Now, changes push properly to github again, but I cannot see production heroku logs using the CLI.
How is this so confusing? I tried a ton of googling for guidance git-config but encountered explainer after explainer just going step by step through typing shell commands to set things up and not really discussing WHAT IN THE WORLD is going on inside the .git/config file.
I appeal to my amazing DEV.TO friends for help here. Explain this whole .git/config to me like I'm 5.
FWIW - mine looks something like:
[core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = true [branch "master"] remote = production merge = refs/heads/master [remote "heroku"] url = firstname.lastname@example.org:myapp.git fetch = +refs/heads/*:refs/remotes/heroku/* [remote "production"] url = https://github.com/me/myapprepo.git merge = refs/heads/master [remote "staging"] url = https://git.heroku.com/adjective-noun-number.git fetch = +refs/heads/*:refs/remotes/staging/* [heroku] remote = staging [push] default = tracking
(open source and trusted by devs everywhere ❤️)