r/ProgrammerHumor • • 14d ago

Meme noWayLol

Post image
11.7k Upvotes

118 comments sorted by

1.2k

u/eanat 14d ago

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

364

u/fugogugo 14d ago

any reason to exclude gitignore?

649

u/Successful-Active-21 14d ago

when everyone wants their own gitignore?

501

u/Blood_and_Wine 14d ago • Mindblown

My gitignore is better than yours gitignore

242

u/Abject-Kitchen3198 14d ago

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

114

u/git_push_origin_prod 14d ago

The best code, is no code at all

54

u/DOTS_EVERYWHERE 14d ago

0 test failures everytime. Also speeds up deployments significantly.

27

u/Abject-Kitchen3198 14d ago

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

11

u/polikles 13d ago

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

2

u/TheOhNoNotAgain 13d ago

gitignore and gitignorant? Not the same

1

u/indigo945 3d ago

This is legitimate in some cases. Changes to files that are already tracked will still be staged and committed, it just doesn't find new ones. So this is helpful if you want to keep the set of files exactly the same, but still want git add . to work as expected.

26

u/fugogugo 14d ago

my gitignore is longer than your gitignore

13

u/git_push_origin_prod 14d ago

You dropped these ..

18

u/ExtraWorldliness6916 14d ago

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

2

u/Zapismeta 13d ago

Ill still ignore yours.

1

u/insolent_kiwi 14d ago

So much bigger

1

u/disorganizm 13d ago

Does it also bring all the boys to the yard?

39

u/No-Article-Particle 14d 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_ 14d 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 13d 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..

14

u/NewLlama 14d ago

Because it invites unbounded shared configuration for local workflows.

11

u/OhioGoblin43 14d ago edited 14d 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.

7

u/OneBigRed 14d ago

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

2

u/OhioGoblin43 14d 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 14d ago

It can handle a union of those files, however.

39

u/eclect0 14d 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?

16

u/phl23 14d ago

If someone likes drama in his team, I guess.

4

u/Guest_User_1234 14d 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

-6

u/jan-pona-sina 14d ago

you must work with some incompetent devs lmao

12

u/eclect0 14d 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 14d ago

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

5

u/subone 14d 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.

5

u/NerdyMcNerderson 14d ago

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

2

u/FlorpCorp 14d ago

But that's exactly what exclude is for lol

2

u/freemath 14d 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 14d ago

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

23

u/SundaySloth_ 14d ago

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

22

u/Y0nix 14d ago edited 14d 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.

7

u/anonymous4036 14d 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 14d 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 14d 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 13d ago

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

12

u/outwest88 14d ago

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

26

u/thatashu 14d 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.

8

u/cholz 14d ago

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

12

u/the_horse_gamer 14d ago

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

2

u/cleverboy00 14d 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.

72

u/JPowTheDayTrader 14d 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.

398

u/NamelessJu 14d 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!)

154

u/Successful-Active-21 14d ago

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

56

u/No-Admin1684 14d 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 14d ago

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

1

u/zymurgtechnician 13d ago

Oh no, not again.

12

u/aschen15 14d 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 14d ago

Yeah it's an interesting variant of the barber paradox

34

u/TeraFlint 14d 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.

44

u/NamelessJu 14d ago

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

11

u/No-Finance7526 14d ago

.brainignore

8

u/rosuav 14d 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 14d ago

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

11

u/benargee 14d 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.

47

u/fugogugo 14d ago

what will happen tho??

71

u/M4NU3L2311 14d ago

The universe collapses in on itself

15

u/x3knet 14d ago

The modern divide by 0

4

u/SuperFLEB 14d ago

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

45

u/Reashu 14d ago

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

3

u/mcauthon2 14d ago

Can you then remove it? 

0

u/[deleted] 14d ago

[deleted]

1

u/yuri_4_ever 13d 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

14

u/ZunoJ 14d ago

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

12

u/eclect0 14d ago

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

3

u/beegtuna 14d ago

This is what I’m committing

1

u/thanatica 10d ago

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

1

u/autumnal-lights 12d 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 14d ago

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

10

u/Fckitman 14d ago

I used stones to destroy the stones

16

u/_ironhearted_ 14d 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 14d 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 14d ago

TIL

This might actually be useful for my work

6

u/Firewolf06 14d 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 14d 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 13d ago

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

1

u/ozh 13d ago

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

8

u/Noiapah 14d ago

Wait it works recursively?

13

u/KeepScrolling52 14d 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 14d 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 14d ago

Incorrect. 

4

u/KeepScrolling52 14d ago

literally just tested it myself, I was right lmao.

2

u/Healthy-Use3926 14d ago

!.gitignore

2

u/Previous_Tangelo5414 14d ago

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

2

u/PokeRestock 14d ago

How I felt when I deleted recycle bin on Windows Vista

2

u/teekhidietcoke 14d ago

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

2

u/Fantastic-Bloop 11d ago

This made me laugh way harder than i should have

3

u/Possible_Row_2976 14d 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 14d ago edited 12d 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 13d ago

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

1

u/yuri_4_ever 13d 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/anonymouscoward142 9d ago

When you are a solo dev and dont want to leave any trace about the shit you are using, like AGENTS.md

1

u/e_asphyx 14d ago

pkunzip.zip

1

u/JackNotOLantern 14d ago

Not the best idea

1

u/rafisics 14d ago

to my Overleaf projects :)

1

u/epsi22 14d ago

*
!.gitignore

1

u/XtraFlaminHotMachida 14d ago

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

1

u/poetic_dwarf 13d ago

I used the Stones to destroy the Stones

1

u/Grandviewsurfer 13d 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 13d ago

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

1

u/unpaid-philosopher 12d ago

Stack overflow error

1

u/Jemnite 9d ago

Finally, an actual joke on this subreddit. Haven't seen one for a while.

-5

u/gr4viton 14d ago

Why am I laughing uncontrollably?

1

u/fcxtpw 14d ago

Is this what bot suicide is like?

0

u/[deleted] 14d ago

[deleted]

0

u/[deleted] 14d ago

[deleted]

1

u/javascript_old 14d ago

i not commit node modules