I'm having trouble with this Git issue and I cannot seem to resolve it.
I have a node that I've been building and I've finally reached the point of deploying it.
I'm trying to push files directly to my app on Heroku. I know that I can simply pull the data from a Github repo but I'd like to avoid having my private keys public, obviously, so I created a custom module for the keys to be accessed (e.g., "modules/private-variables.js"). This file is included in the .gitignore so I don't push it to my Github, which is publicly viewable.
When it came time to push my app to Heroku, for whatever reason I can not push that file specifically.
git add -f modules/private-variables.js
For whatever reason this is not working. It's still replying that "Everything is up-to-date"
$ git add -f modules/private-variables.js
$ git commit -m "7th attempt to include necessary file"
$ git push heroku master
I even did "git commit -a"
$ git add -f modules/private-variables.js
$ git commit -a
$ git push heroku master
I've ran "heroku run bash" and concluded that my file was still not there.
Admittedly I am still relatively inexperienced with Git but this is the first time I've tried to include a file that was once in the .gitignore, so I've never had this issue. I even tried deleting the one line from .gitignore.
Any helpful tips would be much appreciated.
To deploy your app to Heroku, use the git push command to push the code from your local repository's main branch to your heroku remote. For example: $ git push heroku main Initializing repository, done.
Reason: It maybe that your github default branch is main and not master or vice versa. So to solve this problem you will have to use your actual github default branch. In my case, I got the error because my github default branch isn't master but main .
All Github provides is an additional place to store your code if you are working on it in a team. There is absolutely NO REASON that you have to use github to use Heroku.
You can use && as well to chain the commands i.e. git push origin master && git push heroku master. This will enable you to push on both platforms easily.
I was able to solve this on my own after some time.
The issue was that I was using a different branch to push to Heroku. See, as I said before I'm still lacking in knowledge of how Git works.
I thought that when I did...
$ git push heroku master
... while on my branch "deploy" I would simply be pushing the files currently present.
I now know that this is not the case. I have to push the "deploy" branch to "master" on Heroku.
According to this answer: https://stackoverflow.com/a/11143639/4107851
I have to do "git push heroku [name of branch to push]:master
$ git push heroku deploy:master
I haven't tried this exact method yet. I simply went back to my master branch, included the ignored file, and pushed it up to Heroku. Now that I know this about Git I'm sure this'll make future development much easier (and less of a headache).
You learn something new everyday. :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With