I'm using dotenv for my rails project to store API keys. I have the dotenv gem in my gemfile, created a .env in the root of my app and have my API keys listed in there. However, when I push up to github, I notice that the .env file is still there. Am I missing a step? How can I hide the .env file from being uploaded to github.
Thank you!
Create a file called . gitignore in the root directory of your project (it's possible one is already there) and add . env on its own line in the file. Also, if you have already added it to your repository, then you will have to add the file to .
You should use your . gitignore file to ignore the . env file.
env is a secure environment config section in your projects, useful for storing API keys and app credentials.
env files for my backend application and the usual recommendation is to put all . env files in gitignore to not share it in the repo and use something like Github Secrets to store the . env files.
Create a file called .gitignore
in the root directory of your project (it's possible one is already there) and add .env
on its own line in the file.
Also, if you have already added it to your repository, then you will have to add the file to .gitignore
as stated above and then clear Git's cache. You can find information on that in the following answer on StackOverflow.
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