Live data from Hacker News

.gitignore Everything by Default

packagemain.tech

131–140 of 182 posts

Re: .gitignore Everything by Default

#131

- or you could stop scratching your head so hard and actually use the gitignore templates for every programming language officially recommended by github itself - https://github.com/github/gitignore - funny how I did not see a single comment talk about this

I don't like them, because they contain all sort of crap, that never even enters my projects, but they don't include things they should include, like the silly ".vscode" folder so many people commit without thinking. Also usually using these templates one avoids thinking and knowing what is ignored, until one accidentally commits something special to the project and boom, creating a huge hassle.

Re: .gitignore Everything by Default

#132
I’ve been liking keeping sensitive config outside of the repo directory altogether, and instead putting it into a dotted folder in my home directory, so something like

~/.project-name/local.env

And then referring to that location in the repo, say from a docker compose file.

Works well so far

Re: .gitignore Everything by Default

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

> Keys, npm directories and huge binaries are fixed by deleting them later on. The horror.

Keys that are deleted are not gone from the git history. They’re still in the repo.

Same with giant blobs and binaries.

Re: .gitignore Everything by Default

#134
post #133
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.

> Keys, npm directories and huge binaries are fixed by deleting them later on. The horror. Keys that are deleted are not gone from the git history. They’re still in the repo. Same with giant blobs and binaries.

That's the horror..

Re: .gitignore Everything by Default

#135
post #101

Earlier quoted context omitted.

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

I guess your being downvoted around not being in favor of CLI is typical at HN...

Re: .gitignore Everything by Default

#136

Earlier quoted context omitted.

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.

but if I add that to my user-global config instead of the projects I'm working with, I'd be making the deliberate choice of fixing things only for me and not anyone else for pretty much the exact same cost.

I think rules for your personal tools, like editor-specific ignores belong to your user-level config, but anything around the project's tools and artifacts belongs in the project's gitignore.

Re: .gitignore Everything by Default

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

It is easy to do a rebase, adding more files to an already pushed commit. It is impossible to be sure, that no one has read already leaked secrets. Err on the side of caution.

Re: .gitignore Everything by Default

#139
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 :)

There's -i for interactive, lets you add, patch and reset (unstage).

Re: .gitignore Everything by Default

#140
post #66

Earlier quoted context omitted.

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!

You can just add it in a user-level gitignore instead of ignoring it in every repo. See: ~/.config/git/ignore

This has the disadvantage though, that this user level gitignore file will not be in the repo, which means that other less careful contributors have to fix ignoribg for themselves.
Post reply on HN