Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to store .env file in github?

I have a node.js project with .env file in it. I pushed to github project, when in .env file was just a template. For example:

# Database credentials
DB_HOST=""
DB_USER=""
DB_PASSWORD=""
DB_DATABASE_NAME=""

Then I added .env file to .gitignore. Pushed again and now, when I filled .env file with credentials, git status command says

modifed: .env

How can I store a template of .env file in github and ignore it's changes?

like image 263
Don2Quixote Avatar asked Jan 20 '26 00:01

Don2Quixote


1 Answers

When we need to provide templates for environment files or secrets, we tend to add a .sample to the file name. That's has been mine and my workplace convention, and a lot of people follows it. So you can have files like .env.sample and secrets.sample

like image 188
Faizaan Khan Avatar answered Jan 21 '26 22:01

Faizaan Khan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!