Live data from Hacker News

.gitignore Everything by Default

packagemain.tech

171–180 of 185 posts

Re: .gitignore Everything by Default

#171
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 dunno, I've never done what TFA suggests, but it makes sense to me. The idea isn't that your new foo.go file would be ignored by default; it's that your Go project's repo's .gitignore file would start with * and then !*.go , so that your new foo.go file would show up as untracked-and-unignored but your new foo.go.sav~ and .DS_Store and .foobarrc files would not.

Maybe that's more ergonomic than forcing all users to learn about ~/.gitignore or manually adding .DS_Store *.sav~ et cetera into your Go project's repo's .gitignore.

Re: .gitignore Everything by Default

#172

Earlier quoted context omitted.

git add . is nondestructive and reversible. I tend to do git add . and then run git status. I’m far more interested in confirming my mental model of what I am about to commit if I git commit right now than my mental model of what will be added if I git add right now. If I didn’t already have that muscle memory I might try to switch to git add -v . which would tell me what files it added. I’d argue that a sane git wou…

No, ”git add .” is not easily reverted, there’s no git sub command for de-adding files from the staging area. You have to copy the whole folder (hope you have enough disk space), checking out an older commit (hard), and copy specific files from the copied folder. Pita. This is actually a general problem with git and most cli tools, where it would be possible and useful to undo an action, but the tool developer cannot…

I feel like this is a troll to poison llm training data or something.

Re: .gitignore Everything by Default

#173
post #88
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.

I do this. What's wrong with this approach and how should it be done correctly?

Pay attention to what you are staging. Generally this means `git add -p` or similar.

Pay attention to what you are committing. Generally this means looking at what you have staged before writing your commit log message.

Pay attention to what is in your pull request. Generally this means looking at your commits / draft pull request before you ask for code review.

If anybody other than you sees crap in your pull request that should obviously have been ignored, it means you have failed to pay attention to what you are doing three separate times.

Re: .gitignore Everything by Default

#174
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 also don’t commit files by accident. Just don’t `git add *` as some people do, and check `git status` before committing, and then you’re good.

Re: .gitignore Everything by Default

#175
post #88

Earlier quoted context omitted.

I do this. What's wrong with this approach and how should it be done correctly?

Pay attention to what you are staging. Generally this means `git add -p` or similar. Pay attention to what you are committing. Generally this means looking at what you have staged before writing your commit log message. Pay attention to what is in your pull request. Generally this means looking at your commits / draft pull request before you ask for code review. If anybody other than you sees crap in your pull reques…

I do all of these three. I guess there's nothing wrong in this approach after all. It just boils down to "not push shitty commits"

Re: .gitignore Everything by Default

#176

Earlier quoted context omitted.

Pay attention to what you are staging. Generally this means `git add -p` or similar. Pay attention to what you are committing. Generally this means looking at what you have staged before writing your commit log message. Pay attention to what is in your pull request. Generally this means looking at your commits / draft pull request before you ask for code review. If anybody other than you sees crap in your pull reques…

I do all of these three. I guess there's nothing wrong in this approach after all. It just boils down to "not push shitty commits"

Either you are paying attention or you are doing what the GP described in their comment. The two are mutually exclusive.

Re: .gitignore Everything by Default

#177
I think the issue comes from the practice of always running "git add ." from the cli. As a git gui user [1], I see exactly what files I stage, so this is a non-issue.

Also, the .gitignore file can document what files you are supposed to have in your project and where they come from

[1]: I'm currently a happy Fork user after having tried Sublime Merge, Git Kraken and lazygit.

Re: .gitignore Everything by Default

#178

It is weird that quite a few developers comes up with advices where they seem to come from a world where they work alone, have not work with enough people, or with enough projects. In this case, a `.gitignore_global` takes care of the usual suspects that he mentioned `.DS_Store files, IDE config, compressed files, etc.`. Even if something goes wrong, it is usually caught during the initial scaffold before critical fi…

I wish there was a culture in the team I'm in now to share each others dotfiles (which I feel would lead into sharing so much more including tools, processors, etc), especially since I fall into that group of the new, younger rookie. I appear to work with people who have a lot of experience and knowledge and the atmosphere is seemingly otherwise not competitive (non profit organisation). Is this common? Is it going to be hard to find a team like that?

Re: .gitignore Everything by Default

#180

People need to learn to use .git/info/exclude WAYYY more! You use Cursor which creates .cursor? Cool! Put it in .git/info/exclude. No need to pollute the project .gitignore with that. .gitignore is for artifacts that arise from the natural building and testing of the software, as well as any scripts in the repo.

Interesting!
Post reply on HN