https://github.com/dtkav/igit
I keep a lot of private files alongside my public repos — deployment configs, `.env` files, etc. Everything that makes the generally-useful open-source project tailored to me. They're gitignored so they don't end up on GitHub. But I also don't want to lose them, and I'd love version history.
I was going to use a second git repo, but I wasn't excited about git-ignores and needing to maintain a second gitignore that's the inverse of the first one.
Instead of hand writing inverse gitignore files, I thought it would be fun to fork git and patch it to interpret gitignore backwards/upside-down/inside-out.
```diff
- return pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1;
+ int excluded = pattern->flags & PATTERN_FLAG_NEGATIVE ? 0 : 1;
+ return core_invert_exclude ? !excluded : excluded;
```
That's most of it. I changed the default directory from `.git` to `.igit`, flip the result of `is_excluded()`, and now you have `igit`, a git that only sees gitignored files.
```
$ git status
On branch main
nothing to commit, working tree clean
$ igit status
On branch main
Untracked files:
.env
fly.toml
```
Of course, some files (like build artifacts) aren't really useful in either world.
Enter `.igitignore` - these are ignored by igit.
```.igitignore
# .igitignore
# build artifacts
dist/
```
Collecting quirky tools like this is my favorite part of software engineering =]
Ad Astra