Hacker News·2 min read·medium

.gitignore Everything by Default

D
der_gopher
.gitignore Everything by Default
AI Summary

A developer proposes a 'deny-by-default' strategy for Git repositories by using a restrictive .gitignore file that only tracks explicitly allowed files. This approach aims to prevent the accidental inclusion of sensitive environment variables or unnecessary configuration files.

Why it matters

It offers a practical security and hygiene improvement for software development workflows to prevent data leaks.

Dive DeeperCreate a free account to unlock

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:

* !.gitignore !*.go !README.md !go.mod !go.sum This .gitignore file does exactly that:

Continue reading on Headlinne

Create a free account to read the full article.

Read full article →
technologybusiness

Get smarter about the news

Sign up free for a feed built around what you actually care about, Dive Deeper research on any story, and the full text of every article.

Create free account

Already have an account? Sign in