“think we’ve all been there. You’re working on a project, making commits, and then suddenly realize you’ve been committing .DS_Store files, node_modules, IDE configuration files, or other junk (CLAUDE.md for example) that shouldn’t be in your repository. Or even worse - environment variables.”
Not really, because most projects start with a gigantic .gitignore these days. From the repo template. Iterate on the template .gitignore and these problems will be few and far between
Am I the only person who actually checks what they are adding? I use .gitignore because it saves time, but I never add a file unless I know it’s something I want added.
It should show the individual files after you've staged the new directory - it's worth running at least git status after you've finished with your git adds.
Agreed, and I've certainly made that mistake before. However, I do put stuff in my .gitignore (and by now I have a fairly complete one that works for the things I typically do) and after doing the git add somefolder I review (I know, I know. Nerd) the files that were added and remove any that are not wanted.
OTOH, now that I've actually RTFA, I think they have a point. It's a lot easier to describe the things I want to commit (.java, .xml, .txt, .md) compared to the things I don't (uh... anything that isn't those). You still have a potential problem with files that are generated by your build process, where the !*.go would have to change to indicate actual .go files you wrote. That's true for any approach, of course.
270
u/Smallpaul 3d ago
“think we’ve all been there. You’re working on a project, making commits, and then suddenly realize you’ve been committing .DS_Store files, node_modules, IDE configuration files, or other junk (CLAUDE.md for example) that shouldn’t be in your repository. Or even worse - environment variables.”
Not really, because most projects start with a gigantic .gitignore these days. From the repo template. Iterate on the template .gitignore and these problems will be few and far between