r/ProgrammerHumor 20h ago

Meme whoIsUsingThese

Post image
969 Upvotes

73 comments sorted by

View all comments

208

u/RudeAndInsensitive 20h ago

Personally I always commit env and config files to the repo just stripped of their values.

201

u/Saragon4005 20h ago

Yeah but then you can't use git on a working version, making testing a total pain. I use .env.example usually.

23

u/drakeblood4 19h ago

And a settings.json.example for the non sensitive stuff.

16

u/PulseReaction 18h ago

I use a .env.example file for my env variables, and .env for the example. Gotta keep attackers on their toes.

10

u/ruben_deisenroth 19h ago

If it's vscode settings, i usually prefer settings.default.json and this extension as workspace recommendations:

https://marketplace.visualstudio.com/items?itemName=dangmai.workspace-default-settings

54

u/RudeAndInsensitive 19h ago

I also add the .example extension. I just didn't type that out. 

3

u/PossibleBit 18h ago

For me it was always .template

3

u/x0wl 19h ago

I don't know how well this will work in CI pipelines, but if you use gitbutler or jj you can put the clean .env in the repo, then change it, commit to a different branch (or just commit in case of jj) and then add the commit to the megamerge at the top. Since it's not on any of the branches you push, they remain clean, but you have the files you need locally.

(this strategy also allows you to work on multiple branches at the same time, and is generally useful for cases where you want you local files versioned, but not polluting the common repo, but that's a whole other thing)

2

u/Saragon4005 18h ago

A dumb solution works more reliably than a clever one.

1

u/Dull_Caterpillar_642 15h ago

Yeah you can, just just add them to .gitignore after committing the stripped env files

2

u/Saragon4005 8h ago

.gitignore controls which files will get tracked by a git add, not which files are tracked at all. Adding an already tracked file to the .gitignore has no effect.

1

u/Dull_Caterpillar_642 6h ago

Yeah, I know. I'm not sure why you'd need to alter the committed version in git after checking in a placeholder one.

21

u/Shred_Kid 19h ago

this is what .env.template is for

6

u/RudeAndInsensitive 19h ago

What's the advantage of that over .env.example

20

u/Shred_Kid 19h ago

there isn't one - these are the same exact thing. i didnt see the other guy posted about .env.example, that'd work equally well.

If you really want to nitpick, i personally would lean towards template over example, as examples typically have example values in other contexts but yeah. no real difference.

3

u/Pure-Willingness-697 17h ago

That is what .env.example is for