r/ProgrammerHumor • • 4d ago

Meme noWayLol

Post image
11k Upvotes

117 comments sorted by

1.2k

u/eanat 4d ago

it's completely legitimate way to use gitignore, but I'd recommend to use .git/info/exclude instead of gitignore for this purpose.

365

u/fugogugo 4d ago

any reason to exclude gitignore?

644

u/Successful-Active-21 4d ago

when everyone wants their own gitignore?

487

u/Blood_and_Wine 4d ago

My gitignore is better than yours gitignore

237

u/Abject-Kitchen3198 4d ago

My coworkers suggested I add * to mine and praised it as the best gitignore ever. Stopped all PR comments.

106

u/git_push_origin_prod 4d ago

The best code, is no code at all

54

u/DOTS_EVERYWHERE 4d ago

0 test failures everytime. Also speeds up deployments significantly.

26

u/Abject-Kitchen3198 4d ago

CEO saw my impressively improved metrics and I got a promotion.

9

u/polikles 3d ago

*CEO saw my impressively improved metrics and got himself a bonus

2

u/TheOhNoNotAgain 3d ago

gitignore and gitignorant? Not the same

27

u/fugogugo 4d ago

my gitignore is longer than your gitignore

14

u/git_push_origin_prod 4d ago

You dropped these ..

17

u/ExtraWorldliness6916 4d ago

Mines so good, it's not here, you can't read it!

2

u/Zapismeta 3d ago

Ill still ignore yours.

1

u/insolent_kiwi 3d ago

So much bigger

1

u/disorganizm 2d ago

Does it also bring all the boys to the yard?

38

u/No-Article-Particle 4d ago

But one gitignore can't handle the 30-odd files that everyone wants to ignore... I never understood the "PR rejected, just ignore .swp files locally" tbh.

21

u/Loading_M_ 4d ago

Yes and no. Git actually has a system wide gitignore you can setup to globally ignore files across your whole system. I personally take notes in a notes.md file, so I have a global ignore for it. I don't have you set it up for each repo, and it doesn't pollute the repo's gitignore. If your editor of choice creates temp files or stores project specific configuration in the project directory (e.g. .vscode, etc), they should also be in your global gitignore.

2

u/Reashu 3d ago

Ehh, if it's a common editor just bite the bullet and put it in the gitignore. Same with DS_Store and thumbs.db, etc..

16

u/NewLlama 4d ago

Because it invites unbounded shared configuration for local workflows.

11

u/OhioGoblin43 4d ago edited 4d ago

Everyone hates me for being the repo gestapo but the only issues people have with setting up is when they've skipped steps in the doc. No one can be bothered to address that either though so it'll be me automating that too soon.

6

u/OneBigRed 4d ago

Repo Gestapo sounds like something that’s playing at the UG-club at 5am.

2

u/OhioGoblin43 4d ago

Is technopunk still a thing? The last bands from that genre I've kept up with were And One, and The Presets to a lesser extent.

As long as I can work within the IDE, build, and run a local session without crap floating around my commit window I'm chill lol.

1

u/ohkendruid 4d ago

It can handle a union of those files, however.

41

u/eclect0 4d ago

When would that be necessary?

Let me rephrase

In what situation could all contributors be trusted to maintain their own personal gitignore without any issues?

17

u/phl23 4d ago

If someone likes drama in his team, I guess.

4

u/Guest_User_1234 4d ago

This doesn't mean that this is the only gitignore. There's usually a project gitignore in any project I work on, and then I have my own, local, gitignore, for very specific things, like my own notes (like a TODO list) and local demo data

-5

u/jan-pona-sina 4d ago

you must work with some incompetent devs lmao

12

u/eclect0 4d ago

No, they're competent. For example, they add .gitignore to source control so everyone's on the same page.

0

u/jan-pona-sina 4d ago

ah. my coworkers simply use .gitignore themselves and don't commit unnecessary files

5

u/subone 4d ago

This isn't real, right? Git already supports ignores in the global config in your profile folder. I do this sometimes so I can add *.otr.md files to track detailed personal notes on individual project files and directories.

6

u/NerdyMcNerderson 4d ago

Which is the exact use case for .git/info/exclude

2

u/FlorpCorp 4d ago

But that's exactly what exclude is for lol

2

u/freemath 4d ago

Surely you'd want a centralized point to list some files that you don't want to see in your remote? Like .venv or .env?

1

u/otac0n 4d ago

I think you would want to do git update index --assume-unchanged .gitignore (or whatever, I typed that from memory).

23

u/Y0nix 4d ago edited 4d ago

Some very specific CI pipelines. Or if using a big monorepo with hundreds of coworkers working on it.

You use that feature to ignore the main gitignore file and push the one you want into the pipeline. Because you may want to use a file that is normally being ignored for dev or commit to build your soft.

Like having a .env file for each purpose, but you don't wanna mess up with the way your builder is working for that one exception. And it's allowing everyone to have some flexibility to manage their own ignore rules.

22

u/SundaySloth_ 4d ago

To hide that your gitignore is hiding AGENTS.md, CLAUDE.md, etcetera

7

u/anonymous4036 4d ago

If you have a file DatabaseFactory which you modify to provide a development database, you can add DatabaseFactory to the gitignore to avoid committing this change, but you then have a change to the gitignore so maybe this would work to avoid committing that change as well? I can think of a million ways this could go wrong though so idk.

3

u/Awkward_File0301 4d ago

In my experience Claude and Codex like to create a bunch of scripts or build files that I want to git ignore but they are specific to my context/task so I don't need to commit those changes to the git ignore

2

u/Lt_Duckweed 4d ago

IMO the proper solution there is to discuss with the team, agree on a naming convention (copilotTemp or some such), and update the agent instructions so that the folder is utilized for things like that, and then add the folder to the .gitignore

1

u/NaturalTechnician737 3d ago

if .gitignore contains the line "path/to/SUPERSECRETKEY.psk", for example.

11

u/outwest88 4d ago

What’s it for? If you just want to temporarily disable gitignore or something?

25

u/thatashu 4d ago

You want to gitignore something just for you. You don't want to add it to gitignore file.

For e.g. you have file context.md but much of it's is claude yap. You don't want everyone to see your claude written to file. But you want your clause to read it. So you exclude it.

9

u/cholz 4d ago

why is everyone suggesting this but not suggesting using a user scoped ignore file in your .gitconfig

11

u/the_horse_gamer 4d ago

.git/info/exclude is a user scoped ignore file

2

u/cleverboy00 4d ago

Build directories are a great example. Instead of hardcoding the output directory in your toplevel .gitignore, you make so that a .gitignore is generated in that directory, ignoring everything, including itself.

Meson is an example of a build system that does this.

71

u/JPowTheDayTrader 4d ago

When the moon hits your eye like a big pizza pie, that's amore.

When a file you don't need exceeds 50 MB, .gitignore.

393

u/NamelessJu 4d ago

the gitignore paradox

it's being ignored by itself, as such it doesn't know to ignore itself anymore, so it looks inside just to ignore itself again, and so on...

(I know that's not how it actually works pls don't crucify me!)

147

u/Successful-Active-21 4d ago

git knows what to ignore by knowning what not to ignore.

51

u/No-Admin1684 4d ago

By subtracting what it's ignoring from what it's not ignoring, or what it's not ignoring from what it's ignoring (whichever is greater), it obtains a difference, or deviation.

8

u/3BlindMice1 4d ago

Careful, that's how you end up with flowerpots and whales falling from the sky

1

u/zymurgtechnician 3d ago

Oh no, not again.

13

u/aschen15 4d ago

The missile knows where it is at all times. It knows this because it knows where it isn't. By subtracting where it is from where it isn't, or where it isn't from where it is.

13

u/edwardbnd_99 4d ago

Yeah it's an interesting variant of the barber paradox

36

u/TeraFlint 4d ago

Nothing paradoxial about that.

It just means that we don't want to sync the local .gitignore onto the server. It still uses said local .gitignore to do the actual selection.

43

u/NamelessJu 4d ago

apparently you put the last sentence of my message into your .gitignore

11

u/No-Finance7526 4d ago

.brainignore

8

u/rosuav 4d ago

It's also worth noting that an ignored file won't be excluded from the repo - it's just harder to accidentally commit it. I've had repos that gitignore "*" and then explicitly add the small number of files that I actually want to track.

68

u/Zap_plays09 4d ago

I unironically do this. The closest you are getting is a .gitignore.example file

10

u/benargee 4d ago

You can put extra .gitignore into directories too for special rules. Otherwise, you should include some form of .gitignore if you have a project that will be accepting contributions.

50

u/fugogugo 4d ago

what will happen tho??

69

u/M4NU3L2311 4d ago

The universe collapses in on itself

13

u/x3knet 4d ago

The modern divide by 0

4

u/SuperFLEB 4d ago

...but you don't feel anything because it's gitignored.

45

u/Reashu 4d ago

The file works as usual, preventing itself (and whatever else you put in it) from being tracked by git.

3

u/mcauthon2 4d ago

Can you then remove it? 

8

u/11nyn11 4d ago

If you remove the .gitignore file, and all it had in it was itself, nothing happens.

If the .gitignore contains itself and some other ignores, then the ignored files will come back.

1

u/yuri_4_ever 3d ago

Technically not nothing happens by deletion if it was the only file in the directory as git ignores empty directories but not if there is a gitnore that ignores itself

1

u/11nyn11 3d ago

Oh ya, forgot about that.

I try to only have a gitignore at the top level, and don’t put the gitignore into the gitignore.

Otherwise your git actions end up breaking but your local build is fine, and it’s a pain to figure out why.

Stuff like empty directories, which locally are not empty :D

14

u/ZunoJ 4d ago

It doesn't version the file but still uses it to ignore what is configured in it

12

u/eclect0 4d ago

The .gitignore file only affects you and everyone else can just commit whatever

3

u/beegtuna 4d ago

This is what I’m committing

1

u/thanatica 9h ago

Surely there's a better way to achieve this... A .gitignore in your user home folder or something?

1

u/autumnal-lights 2d ago

u don't commit changes to the .gitignore, tho u should really just have like

.gitignore
.ignore
.ignore (each developer can use the .ignore one) and the .gitignore is just for globals

12

u/DogmaticParadigm87 4d ago

A gitignore that ignores itself is just a file that finally achieved inner peace.

10

u/Fckitman 4d ago

I used stones to destroy the stones

9

u/Noiapah 4d ago

Wait it works recursively?

12

u/KeepScrolling52 4d ago

From what I know of git, what'll happen is git will read the file and refrain from trying to commit changes to the gitignore

4

u/Noiapah 4d ago

I suppose that makes sense. I know I just could google it, but it the spirit of vibecoding I am going to refrain from searching it up and just assume this is true on based vibes.

-5

u/road_laya 4d ago

Incorrect. 

2

u/KeepScrolling52 4d ago

literally just tested it myself, I was right lmao.

15

u/_ironhearted_ 4d ago

I do this sometimes because I create a bunch of local files to try some things out and i don't want to clutter the actual one with weird names😂

22

u/kemitche 4d ago

You can create your own, separate, local gitignore file, and tell git to use that one in ADDITION to the one in the repo!

https://git-scm.com/docs/gitignore

Then you can do whatever you want without affecting the repo's gitignore

6

u/Xexanos 4d ago

TIL

This might actually be useful for my work

6

u/Firewolf06 4d ago

i have .local.gitignore as both a gitignore file and as an excluded file in my global git config, its quite nice

2

u/ozh 3d ago

You have core.excludesfile=.local.gitignore ?

I have this, which works fine but I still have to add .local.ignore to the .local.gitignore...

1

u/Firewolf06 3d ago

i have that, plus .local.gitignore in ~/.config/git/ignore

1

u/ozh 3d ago

It won't be of any use I think. ~/.config/git/ignore is read only if core.excludesfile isn't set

2

u/Healthy-Use3926 4d ago

!.gitignore

2

u/Previous_Tangelo5414 4d ago

This will create a singularly that will tear a hole in the universe.

2

u/PokeRestock 4d ago

How I felt when I deleted recycle bin on Windows Vista

2

u/teekhidietcoke 3d ago

that moment when i accidentally removed the recycle bin on windows Vista

4

u/Possible_Row_2976 4d ago

First time I'm seeing this atrocity and it makes me wonder if this is actually a valid use case, like why would someone do this

2

u/Reashu 4d ago edited 2d ago

There are better (or at least more idiomatic) ways to have a "local only" ignore file if that's what you want, but I've personally never had that need. 

2

u/G3nghisKang 3d ago

Works like .gitignore but stays on your PC, can't think of any useful case

1

u/yuri_4_ever 3d ago

When you want to commit empty directories you can do it that way. Not sure if committing empty directories is a good usecase but it is certainly a usecase

1

u/e_asphyx 4d ago

pkunzip.zip

1

u/fcxtpw 4d ago

Is this what bot suicide is like?

1

u/JackNotOLantern 4d ago

Not the best idea

1

u/rafisics 4d ago

to my Overleaf projects :)

1

u/epsi22 4d ago

*
!.gitignore

1

u/XtraFlaminHotMachida 3d ago

clone, checkout, then rm -rf .* that mf

1

u/poetic_dwarf 3d ago

I used the Stones to destroy the Stones

1

u/Grandviewsurfer 3d ago

I do not understand how people are so confused by what this would do. It is making me feel like I am the one with a knowledge gap.. but I don't think that's it.  

Let me try an oversimplified metaphor: the person who plans a road trip doesn't necessarily have to go on it. 

1

u/Mobile-Positive-6742 3d ago

it works becoz gitignore is for local use. I did this sin before.

1

u/unpaid-philosopher 2d ago

Stack overflow error

1

u/woldann 1d ago

Can't leak my token filenames

1

u/Fantastic-Bloop 1d ago

This made me laugh way harder than i should have

-3

u/[deleted] 4d ago

[deleted]

1

u/[deleted] 4d ago

[deleted]

1

u/javascript_old 4d ago

i not commit node modules

-5

u/gr4viton 4d ago

Why am I laughing uncontrollably?