Live data from Hacker News

.gitignore Everything by Default

packagemain.tech

111–120 of 185 posts

Re: .gitignore Everything by Default

#111
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…

The repo should define rules for the repo, no? You have to hope other contributors have a similar local gitignore?

Re: .gitignore Everything by Default

#112

Earlier quoted context omitted.

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

I usually have *secret in .gitignore and append .secret to any files with secrets.

That's cute, too bad it's a config file mandated by your boss and it has to be called "terribletool.yaml."

Re: .gitignore Everything by Default

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

I have a small user-global gitignore that most of the job for me, ```.gitignore # Ignores ## Unix hidden files .* ## Temporary files and backups *~ *.swp *.bak # Exceptions !.ignore !.gitignore ``` But I tend to copy it over and extend it as I go, and there's well-known reference gitignore files to skim for if you have anxiety around any particular language/editor/tool. Now, I could extend my user-global ignore, but…

> Now, I could extend my user-global ignore

I'd add .nvmrc and .npmrc if you work with NodeJS.

Re: .gitignore Everything by Default

#114
post #111

Earlier quoted context omitted.

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

The repo should define rules for the repo, no? You have to hope other contributors have a similar local gitignore?

For files like `.DS_Store`, technically yes. Usually the people do not have a proper global gitignore, so we put these files in the gitignore of the repo, but it’s not repo-related, it’s OS-related… Same goes for editor files. The editor is something user-related, not project related (except e.g. for iOS development where the IDE is kind of more or less imposed).

Re: .gitignore Everything by Default

#115
This is going to be annoying to live with. It makes `git status` unable to remind you that you forgot to add a file you created. Those files will hang around when you change branches. If you have CI you'll see that it is failing and if you are lucky you'll immediately realize without spending 10 minutes on debugging why, and then have to go backtrack, change the branch back, add the file (without the benefit of copy pasting the path from git status) etc etc.

Just look at git status before you commit :eyeroll:.

Re: .gitignore Everything by Default

#116
post #80
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.

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.

Secrets shouldn't be plain text in project directory >:[

Re: .gitignore Everything by Default

#117
post #74
post #22

Earlier quoted context omitted.

It interactively shows you each change that would be added and lets you decide whether it should be staged or not. Down to the hunk level, so you can partially stage a file if you so choose.

Oh, that's neat. The -p presumably stands for pInteractive with a silent p :)

Ha! It’s actually patch (as in select parts of the patch) though I remember it as partial.

Re: .gitignore Everything by Default

#118

Earlier quoted context omitted.

I usually have *secret in .gitignore and append .secret to any files with secrets.

That's cute, too bad it's a config file mandated by your boss and it has to be called "terribletool.yaml."

Never worked professionally in programming and I was told that home projects is like child's play.

Especially the humility it requires - remember being mad when my younger brother joined my Factorio game and changed smelters setup. To an actually better one - one thing when people correct your technical solutions, double so bad when they are actually right.

Re: .gitignore Everything by Default

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

orr, ~/.gitignore

Re: .gitignore Everything by Default

#120
I set something similar up in a project and it's been surprisingly good. In my case I ignored all top-level except for specific files and dirs such as Dockerfile, src or tests. Juniors rarely (never?) need to add new files or dirs at top-level, and seniors tend to (always?) realise they need to explicitly stage that new dir/file. Other prejects that have the usual exhaustive .gitignore generating from mixing and matching multiple templates ended up with random .claude or .zed once people started using new tools that weren't around when the initial gitignore was created
Post reply on HN