re: Please don't commit .env VIEW POST

re: I see no point in the general advice, not to commit a .env-file per se: I do it frequently and wondered what this post is about. It is not about co...

The only thing I don't like about doing this is that when I change the defaults, they now show up as a diff. On some of my smaller projects I SSH onto the server and just pull the latest changes, so if I've made a change to my default .env file I have to worry about conflicts. I can avoid this problem in production by having the defaults be my production settings, but then I constantly have a dirty file in development.

The best solution to this in my opinion is to not commit .env and instead commit a .env.example. Then all you have to do is cp .env.example .env and you have the exact same things as before but without a dirty file when you change settings.


Hmmm. Interesting. I came into first contact with .env files via vuejs. It seems there, that you have a .env file which acts like your ".env.example" and could have a .env.local which contains overrides.

But doing some research that seems an uncommon practice 🤔

Mostly there is one .env and it isn't committed.

code of conduct - report abuse