简体   繁体   中英

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?

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

您可以使用.env.example文件保存您的 env 模板,然后将其推送到 github,并将.env添加到.gitignore

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM