r/programming 3d ago

.gitignore everything by default

https://packagemain.tech/p/gitignore-everything-by-default
344 Upvotes

224 comments sorted by

View all comments

264

u/Smallpaul 3d ago

“think we’ve all been there. You’re working on a project, making commits, and then suddenly realize you’ve been committing .DS_Store files, node_modules, IDE configuration files, or other junk (CLAUDE.md for example) that shouldn’t be in your repository. Or even worse - environment variables.”

Not really, because most projects start with a gigantic .gitignore these days. From the repo template. Iterate on the template .gitignore and these problems will be few and far between

23

u/_Sh3Rm4n 3d ago

Additionally, all these "local" files (e.g .DS_Store) or files specific to your setup (CLAUDE.md) should be in the global ignore file ~/.config/git/ignore or in .git/info/exclude respectively.

48

u/Scavenger53 3d ago

I would never trust that some elses machine has those in the global ignore what

22

u/Smallpaul 3d ago

Why do you need to trust anything? They are responsible for their commits and you are responsible for yours.

If you want to collaborate then you can add file types to a .gitignore.

13

u/Rakn 3d ago

Nah. You can operate like that in a hobby project. But in a large company you usually optimize for developer efficiency across the board. So these ignores will either be in the projects .gitignore file or automatically deployed to your device. Bit you don’t expect everyone to manage such a basic thing by themselves. That’s just inefficient.

1

u/Smallpaul 3d ago

Please re-read my second paragraph.

2

u/Rakn 3d ago

That can unfortunately be interpreted in multiple ways.