logoalt Hacker News

KPGv2today at 4:46 AM1 replyview on HN

That's a hack. What you should do is a .gitignore with * and then a whitelist of paths like src/**/*.

If you rely on `add -f` you will forget to commit something important.

For example, for a tree sitter grammar I developed a couple years ago, here is my .gitignore:

```

# Ignore everything

*

# Top-level whitelist

CHANGELOG.md

# Allow git to see inside subdirectories

!*/

# Whitelist the grammar and tests

!/grammar/*.js

!/test/corpus/*.txt

# Whitelist any grammar and tests in subdirectories

!/grammar/**/*.js

!/test/corpus/**/*.txt

```*


Replies

beej71today at 8:17 AM

> If you rely on `add -f` you will forget to commit something important.

But isn't the idea in TFA to blacklist the entire `build/` tree? We don't want to add anything there.