Breaking
Police authorities in Belize City are investigating a fatal late-night drive-by shooting that claimed the life of 21-year-old Jaheem SanchezMissing Holland Woman Brittany Ritter Found Deceased in IndianaFranklin Small Business Owner Charity Lynn Maloy Passes AwayBonifay Resident Cortney Nicole Reddick Passes Away at Age 35; Celebration of Life Service ScheduledCommunity members, choir singers, and faith leaders across Southern California are mourning the tragic passing of 33-year-old musician and educator Braden PontoliIndependent Investigation Launched Following Death of Duncan Police Officer Vincent SchenckFresno Rider Gregory Hansen Dies Following Collision With Bicycle-Pulled CartBrother Charged With Murder After GBI Identifies Remains of Missing Dougherty County TeenagerPolice authorities in Belize City are investigating a fatal late-night drive-by shooting that claimed the life of 21-year-old Jaheem SanchezMissing Holland Woman Brittany Ritter Found Deceased in IndianaFranklin Small Business Owner Charity Lynn Maloy Passes AwayBonifay Resident Cortney Nicole Reddick Passes Away at Age 35; Celebration of Life Service ScheduledCommunity members, choir singers, and faith leaders across Southern California are mourning the tragic passing of 33-year-old musician and educator Braden PontoliIndependent Investigation Launched Following Death of Duncan Police Officer Vincent SchenckFresno Rider Gregory Hansen Dies Following Collision With Bicycle-Pulled CartBrother Charged With Murder After GBI Identifies Remains of Missing Dougherty County Teenager
GRC
Technology

.gitignore Everything by Default

I 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. Then comes the embarrassing cleanup: adding these files to .gitignore, removing them from the repository history, and hoping that no one has noticed.

6d ago 2 min 0
.gitignore Everything by Default

I 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. Then comes the embarrassing cleanup: adding these files to .gitignore, removing them from the repository history, and hoping that no one has noticed.

What if we flipped this approach entirely? Instead of allowing everything by default and selectively ignoring files, what if we ignored everything by default and only allowed specific files?

Here’s what this could look like in practice for a simple Go project:

This .gitignore file does exactly that:

* - Ignore everything

But not these files...

!.gitignore - the gitignore file itself

!*.go - Go source files

!go.mod - Go module file

!go.sum - Go dependencies file

anything else you wish to include

With this setup, only the files you explicitly allow will be tracked by Git. No more accidental commits of unintended local files.

The technique isn’t necessarily the right choice for every repository or developer, but is an alternative to explore.

Nowadays, I see that projects have so much crap locally, like various agentic docs or subfolders, so it may seem easier to just ignore everything at first.

Just look at this 207-lines .gitignore from typescript-go.

p.s. if you want to check if the path is ignored by git, you can run this command:

This can save a lot of head-scratching when a file you expected to track doesn’t appear in Git.

p.s. have you heard of lazygit? The best Git TUI out there, check it out.

Discuss this post on Hacker News.

Original source