Live data from Hacker News

.gitignore Everything by Default

packagemain.tech

101–110 of 185 posts

Re: .gitignore Everything by Default

#101

Earlier quoted context omitted.

The problem is that those developers are also going to forget to update the ignore-by-default .gitignore to allow files, so there will be missing files. And they won't see any problems, because it works on their machine.

In my opinion this will pretty quickly solve itself though. Accidentally committing keys to the repo potentially ruins your entire week. With a default disallow all list, you might have one bad deploy oopsie and then commit the files.

One problem I see all the time is that people are not using proper tools.

Yeah command line is cool and all but I do believe most of the developers should be using UI tooling where staging area is showing nice diffs.

Built in GIT handling in IDE usually is better than command line but also usually worse than dedicated tool like GitExtensions or SourceTree which are free and are super convenient for staging.

People don't know they don't have to stage whole files but they can stage hunks, well in command line it is too much hassle for me but in GUI tools it is no brainer.

I recommend looking here: https://git-scm.com/tools/guis

(it might be that you will be waaay cooler using GUI tool because you will be able to fix things others can't ... saying from my experience)

Re: .gitignore Everything by Default

#107
post #13
post #10

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.

>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.

I do that for my personal projects.

Doing that on projects where I collaborate I would equate to pissing in public.

That is also why pull requests are such a great idea in general, because GIT allows one to piss in his own garden as much as they want.

Even if I could piss in my own branch I never do so when working on a project with other people.

I don't piss around my home obviously in case someone didn't get the metaphor.

Re: .gitignore Everything by Default

#108
post #13

Earlier quoted context omitted.

>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.

> people who are lazy and so just do `git add . && git commit -m ... && git push -f origin` every time. People? Even LLMs do that

LLMs learned from people xD

Re: .gitignore Everything by Default

#109
post #80

Earlier quoted context omitted.

Most of the colleagues I've worked with only use "git add ." without checking first. Keys, npm directories and huge binaries are fixed by deleting them later on. The horror.

The problem is that those developers are also going to forget to update the ignore-by-default .gitignore to allow files, so there will be missing files. And they won't see any problems, because it works on their machine.

That's fixed by having the CI server compile the code and run tests, and having it fail the merge and publicly shame the offender in slack when that happens.

It's often said that you can't fix behavioral problems with technology, but I've found that tooling that strictly enforces rules is really useful.

Re: .gitignore Everything by Default

#110
post #10

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.

> why not just do an initial setup step to gitignore the usual files?

Or even better, have a proper global gitignore file on your computer…

Post reply on HN