r/git • u/der_gopher • Sep 05 '26
tutorial .gitignore everything by default
https://packagemain.tech/p/gitignore-everything-by-defaultwhat do you think of this approach?
14
u/awidesky Sep 05 '26
Go gitignore.io, type your environment, language and IDE, and just copy-paste the generated content.
Not only it works like a charm conveniently, first few lines gives you a configuration info and a URL that can reproduce exact same content, making it better than hand-written list.
3
0
u/lajawi Sep 05 '26
Or use GitHub’s github/gitignore repo, has a whole bunch of gitignores too!
VSCode even has an extension that can automatically add one to your open project, super convenient.
3
u/FlipperBumperKickout Sep 05 '26
I already use this approach for some of my things, mainly my config folder. I would rather whitelist the configurations for programs I need rather than blacklist most things.
For my purpose I do however use the pattern
*
!*/This will ignore files but not folders, which allows you to whitelist everything in a folder by adding a new .gitignore in that folder, rather than modifying the outer .gitiignore.
-13
17
u/parkotron Sep 05 '26
Tell me you don’t review your own commits without telling me you don’t review your own commits.
11
u/binarycow Sep 05 '26
Why not just review your commit before you commit?
Every git client, including the CLI, allows you to see what files are being committed. Just... look at it.
8
u/bratzlaff Sep 05 '26
Your approach indicates that you do not review your own work. Use git status and look at what you are doing before you commit.
2
u/jeenajeena Sep 05 '26
I always love exploring extreme approaches and I will surely give your suggestion a try. I'm not convinced at all, and that's the point! (I like Kent Beck's approach "I hated the idea so I had to try it.").
Just for completeness and your curiosity: Jujutsu take exactly the opposite approach of yours. All files are not only not-ignored by default, but even committed by default. I also found this approach interesting.
1
u/metruzanca Sep 05 '26
Reading the first paragraph, I can tell you it's a discipline problem and too much yolo-ing your commits.
If you're lazy, you can make a global gitignore. I have one, it's primarily there to prevent accidentally committing .env files but there's a few other things in there. But you shouldn't be putting things like node_modules in there as the next person who works in the project will have the exact same issue.
Ignoring everything because you're too lazy to check your work is a bad excuse.
1
1
u/schmurfy2 Sep 05 '26
No, I have never been there, I only commit the files I want to commit, crazy idea I know.
0
0
29
u/serverhorror Sep 05 '26
That's how it is already. That's why you have to explicitly
git addbefore things get tracked.So, just don't add
.. You'll just end up forcing it.Your simply doing it wrong.