logoalt Hacker News

rcfoxtoday at 2:46 PM5 repliesview on HN

This seems like bad advice. I've very rarely committed extra files by accident, but I would 100% forget to unignore files I meant to commit.

If you're doing an initial setup step to gitignore everything, why not just do an initial setup step to gitignore the usual files? Make a template that you copy into all of your repos.


Replies

electrovirtoday at 3:52 PM

For many years I've have a git-ignored ".not-committed" folder in all of my repos for throwing extra anything into. It's been a huge life saver!

show 1 reply
traviswingotoday at 3:54 PM

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

aleqstoday at 4:06 PM

You can also use something like alint [0][1] to define and enforce rules about files/globs that should or shouldn't be committed, among other things. You can configure it to run as a pre-commit hook or in CI.

(disclaimer - this is my own tool)

[0] https://github.com/asamarts/alint [1] https://alint.org/docs/rules/git-hygiene/git_no_denied_paths...

grueztoday at 2:51 PM

>This seems like bad advice. I've very rarely committed extra files by accident, [...]

You clearly haven't seen the people who are lazy and so just do `git add . && git commit -m ... && git push -f origin` every time.

show 3 replies
LaGrangetoday at 3:46 PM

Recovery from forgetting to add something is _much_ easier than recovery from adding some weird configuration file with plaintext private keys in it.

show 2 replies