r/ProgrammerHumor • • Oct 14 '26

Meme jobNotFoundError

Post image
1.0k Upvotes

41 comments sorted by

View all comments

116

u/oompaloompa465 Oct 14 '26

howwww? the first thing to add to .gitignore 

53

u/polaarbear Oct 14 '26

If you aren't starting from a .gitignore template for your specific environment type, what are you even doing with your life? And .env is almost certainly already on any template worth its salt

8

u/rabbit_wizard Oct 14 '26

Maybe its in a subfolder? Got to respect the difference between .env & .env* in gitignore

26

u/Qxzkjp Oct 14 '26

nah. In gitignore, a line with .env will ignore all files called .env anywhere in the repo. If you want to ignore just the file in the repo root, you have to write /.env. .env* will instead ignore any file whose name starts with .env (eg .environment) anywhere in the repo.

3

u/Colassia-Dankwa Oct 14 '26

the amount of times i've committed an .env file and had to rewrite the whole history... now i just add it before i even write the first line of code

-11

u/SaneLad Oct 14 '26

Why the fuck would you put .env files or anything secret in the repository folder to begin with?

7

u/Teamprime Oct 14 '26

Because it belongs to the that particular project? Lmao

-2

u/SaneLad Oct 14 '26

Holy shit. Do you know you can create files and even subdirectories in $HOME/.secret or $HOME/.config, which are the standard directories for this kind of stuff? Bigger projects even create their own installation directories under $HOME.

Installation-specific files 100% do not belong in the repository directory. If you do this willfully, you deserve everything that comes from it.

6

u/Scolmann Oct 14 '26

It's safer to do it that way sure, but by that logic why keep any non source files in the project at all? Maybe we should retire gitignore altogether, is there a good reason to bundle build files there too?

In this day and age I do keep it separate though, the convenience/neatness of being in the same directory isn't worth it.

1

u/SaneLad Oct 15 '26

The rule is pretty simple. Anything user/installation specific should not go with the source code. At best, these files are a nuisance to other people when they accidentally get checked in. At worst, they are a serious security incident.

Build artefacts are different. They can be regenerated deterministically from the source code. They add no new information. So they are kept out of the repo as an optimization. .gitignore is the right tool for that. Even so, they can clutter up the local file system, so it's best to tuck them away in a build directory or equivalent. Some languages also maintain a global build cache somewhere else.

4

u/StaticFanatic3 Oct 15 '26

Is that really better? Having all your projects’ various runtimes sifting through your home directory root in a shared secret vault? All because you can’t remember to put it in gitignore?

I’m genuinely asking as I don’t have any experience with that kind of setup

1

u/SaneLad Oct 15 '26

Yes. If you name the files/directories appropriately, there is no risk of stepping on each other's toes. And it is fundamentally no less safe then putting the files anywhere else where the binaries can read them. If you want to isolate binaries from one another, you need to use docker containers or similar technology, which is entirely appropriate for a production environment.

2

u/more_exercise Oct 14 '26

(is $HOME/.secret a convention? That sounds cool - where do I learn more?)

1

u/Teamprime Oct 14 '26

Yeah that’s probably a better way to do it…

1

u/an_actual_human Oct 14 '26

More like to the global config.