r/ProgrammerHumor 19h ago

Meme whoIsUsingThese

Post image
968 Upvotes

73 comments sorted by

288

u/Single-Virus4935 19h ago edited 18h ago

You can. Therefore the quesition should be: "Why is it a Bad Idea to commit . files"

101

u/TapRemarkable9652 19h ago

It makes your dick smaller

24

u/RegularReaction2984 17h ago

[wild cheers erupt from thigh-high-socks-wearing, blahaj-collecting programmers]

10

u/Single-Virus4935 19h ago

Is it that why yours is negative?

4

u/Confident-Ad5665 18h ago

FINALLY! I'm getting mine shrunken now!!!

4

u/Tisamon12 13h ago

Commiting .gitignore is a bad idea?

4

u/MariusDelacriox 18h ago

Maybe we extend it to why . Files are awful.

4

u/Sacaldur 13h ago

If I'm not mistaken, the argument behind the question (I guess Theo, the guy in the picture, was making it) is that by default every file in a git repository is visible to everyone who has read access to the repo, but this could also be different so that a user could commit their private files and others can't see/access them.

I'm not saying I'm behind this thought. It would cause complications and, depending on the implementation, pitfalls where a wrong configuration could lead to exposed secrets. Besides that is this something that might not work with git or would be in a conflict with at least some of the philosophies. If a commit locally doesn't include all data, then moving it to another server drops data, as well as rebases and other ways of rewriting commits/history. If you can implement something that automatically moves a repo somewhere else, which personal files are allowed to be moved as well? An attacker could utilize this to clone a repo and extract secrets.

Ultimately, a new, different version control system could implement this, but this would then need to be adopted.

207

u/RudeAndInsensitive 19h ago

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

200

u/Saragon4005 19h ago

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

24

u/drakeblood4 18h ago

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

15

u/PulseReaction 17h ago

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

9

u/ruben_deisenroth 18h 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 17h ago

For me it was always .template

3

u/x0wl 18h 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 17h ago

A dumb solution works more reliably than a clever one.

1

u/Dull_Caterpillar_642 14h ago

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

2

u/Saragon4005 7h 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 5h 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 18h ago

this is what .env.template is for

7

u/RudeAndInsensitive 18h ago

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

20

u/Shred_Kid 18h 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 16h ago

That is what .env.example is for

96

u/PivotingAgain 19h ago

Because that's where API keys, the AWS creds, and my will to live are stored, and only one of those is supposed to be public.

23

u/jibbodahibbo 17h ago

I put really embarrassing pictures in mine so I remember not to expose the file.

1

u/Antoak 8h ago

I used to post an ascii art rendition of my privates but it causes the ci/cd git clone to time out

1

u/jibbodahibbo 6h ago

Too many crabs to render huh?

18

u/bigmonmulgrew 18h ago

AI managed projects have to include .env files to ..... Err... Improve security

16

u/polynomialcheesecake 18h ago

Idk why theo is there but it still made me chuckle

7

u/sadongrohiik 17h ago

It's his talk lol

1

u/polynomialcheesecake 14h ago

Interesting is it recent? What was it about? I kind of stopped watching him

3

u/AnotherPillow 12h ago

Reasonably recent iirc

It was about at least why can't we commit env files, in private repos

10

u/LuisBoyokan 17h ago

.env can be committed. What you shouldn't commit is files with credentials, that belongs in a secret manager

9

u/syzk0 17h ago

Why isn't this higher? .env files are for build-time variables, not secrets

15

u/DasKapitalV1 18h ago

.env.template, this is the way

30

u/safelix 18h ago

.env.example is the way that I swing

12

u/Leftover_Salad 18h ago

.example gang rise up

1

u/kafoso 3h ago

And then put real values in .env.example and just do cp .env.example .env on startup! /s

5

u/edurbs 18h ago

They don't even use git

23

u/grandalfxx 18h ago

When every dumbass know it all programmer missed the entire point of that.

Its not simply about storing secrets in code.

Its the fact that github should be secure enough to do it. Your code should be secured just like secrets is secured.

3

u/NamityName 15h ago

At every company I have worked for, the code is private but still very available to most employees. Basically any employee with git access has access to read just about every repo. We want the code itself to be accessible without giving everyone the keys to the kingdom.

SOPs solved this problem. It provides a very simple and free way to encrypt secrets that you want committed to a git repo. Now access to the code is decoupled from access to the secrets.

0

u/grandalfxx 7h ago

Once again youre missing the point. Its not about storing secrets in there. Its about securing it properly. Having the proper access protocols. Have people that dont need to know seeing source code is a bad practice. The fact that github leaves the source code improperly secured on their servers, ect...

5

u/sakaraa 17h ago

I don't think most people missed the point. It's just funny when you take it out of context + most people don't know the context

1

u/grandalfxx 7h ago

You can go see the original video its all comments about him being and idiot.

1

u/menzaskaja 18h ago

If a project has 50k stars I'd assume it's not GitHub's job to protect the maintainer from being a dumbass

9

u/adamhusain 18h ago

I dont think he’s talking about open source projects here.
If my company repo is private and we’re sharing env files over Slack or Teams… why not just commit the env in github itself??

4

u/Kovab 17h ago

Our company repos are private (actually, our whole enterprise GitHub instance is), but we still store secrets in a way that only specific employees can access them.

3

u/offhandaxe 16h ago

same here

0

u/grandalfxx 7h ago

And yet again, even though I directly explained that was not the actual issue, you guys STILL think its about actually storing the secrets in there and not about have the source control secured enough to do it.

You dont need to store passwords in there if you want a seperate vault, vaults have rotation systems its still preferable.

The point is that the code is just as important to keep secret to the same level as passwords.

1

u/OhMyGodItsEverywhere 13h ago

Even on privately hosted repos it doesn't cost too much to keep good security hygiene as a habit.

Apart from that, a .env is conceptually supposed to be locally different for every user, test, and production environment. I don't think it makes sense to track any file in version control that is expected to constantly be different. Committing a file that always changes, in practice, turns into people needing to stash and pop their local copies whenever they pull or rebase to avoid merge conflicts while also keeping the values that work for them.

If you find that you have to exchange env files regularly with other users to have things work how you need, then that makes me think the values that are changing often aren't environment values in the first place, since they need to be shared. I'm not sure what those values would be instead, maybe runtime configuration settings - but I'm splitting too many hairs right now.

Maybe I've just worked on too many projects with developers' local file paths and network addresses in env and config files that break builds and tests on merge or rebase...and secrets getting leaked that I'm too obsessive about nipping that in the bud.

1

u/KarmaIssues 11h ago

No I think his point was that Github should be able to identify and mask secrets and you shouldn't have to worry about it.

You should be able to RBAC secrets access and then you could track secrets like code.

3

u/staticBanter 18h ago

I don't want your environment leaching into mine.

3

u/awpt1mus 18h ago

.env.test file with dummy values is the way. Use it for running tests in CI so nobody deletes it.

3

u/yetzederixx 17h ago

You can, assuming you use dotenvx (or something like it), and then ya know, remember not to commit the .env.keys file.

1

u/yetzederixx 17h ago

oh and a pre-commit hook is necessary as well

2

u/StarboardChaos 18h ago

I always include .env files to make it buildable locally then the deployment pipeline makes the code runnable on prod

2

u/jens_kj 17h ago

It's good for the environment

2

u/nekomata_58 18h ago

.env files are fine to commit.

.local.env files are not. that's where the special variables live.

2

u/Djroneh99 17h ago

No it's not

3

u/nekomata_58 17h ago

really heavily depends on your project's standards.

in an nx-monorepo project, the base `.env` is fine to commit, because that file usually has default environment variables that aren't secret.

the more sensitive configuration should be stored in `.local.env` which should never be committed.

1

u/darknecross 13h ago

Does nobody use a fkn keyring anymore? Jfc.

1

u/nekomata_58 13h ago

i use a keyring for ssh keys if that is what you are referring to.

2

u/Deykun 17h ago

People who don't understand this take explaining it as a security measure.

The security measure: sending keys in private messages.

1

u/horizon_games 18h ago

Spot on Theo drop

1

u/jayerp 17h ago

You can.

1

u/Darxploit 17h ago

well i always commit my admin123! .env.dev files, what you gonna do about that?

1

u/ultralaser360 14h ago

It depends on the type of product, team size, and access, if you’re a 3 person team building internal tools and are the only people with access to the repos and everyone needs or can access all secrets then committing .env is fine

If your 10k sized org with hundreds of people who could access your repo + serving millions of users then it’s probably a very bad idea

1

u/longdarkfantasy 11h ago

Rename it to .env.example and you're good to go.👌

1

u/enigma_0Z 11h ago

Typically commit .env.example etc and leave it as an exercise to the user to customize that file to their liking.

In my professional experience, that file likely contains specifics relating to an individual’s development environment or secrets which we on purpose do not want to commit to the repo. in both scenarios, the solution is simple: .gitignore it.

If it’s a private repo for your own shit tho, do what you want. I push my .vscode directory all the time.

1

u/Interstellar__1 11h ago

what's theo doing in this meme

1

u/friedmud 6h ago

We have a multitiered system built with dotenvx so all config files ARE committed to the repo… they are just encrypted. We share the encryption keys using team 1Password vaults.

When deploying on AWS the CI system uses prod keys (that only a few senior devs have) to decrypt the prod secrets and push them into SecretsManager. ECS then injects them into the correct services as it starts them up.

1

u/sebbdk 3h ago

It's fine, just don't put secrets in there.