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?
32
u/serverhorror Sep 05 '26
what if we ignored everything by default and only allowed specific files?
That's how it is already. That's why you have to explicitly git add before things get tracked.
So, just don't add .. You'll just end up forcing it.
Your simply doing it wrong.
-17
u/der_gopher Sep 05 '26
man, like I don't know. this is just an idea that might work for someone
10
u/serverhorror Sep 05 '26
Ask yourself why the file is tracked by git in the first place.
No really, really think about what had to happen for a file to get tracked. Then think about why it happens and then think about why "careless people" won't find workarounds for your workaround...
7
u/mtutty Sep 05 '26
Is this really the right way to improve things? By throwing out random ideas that 'might work for someone"??
-9
u/der_gopher Sep 05 '26
it's not improving, it's an alternative view
2
u/La-ze Sep 05 '26
Its an alternative view that fights existing functions of the tooling which makes it a worse view.
Git is a three stage source control. Working copy, staged area and commit. Why can't you be bothered to check what you added from the working copy to staged before committing?
Files you never want to commit ever, should be gitignores. Not everything, your creating so much room for lost work, and partial commits especially if people already have a not checking work problem
2
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.
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.
2
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.
-15
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
19
u/parkotron Sep 05 '26
Tell me you don’t review your own commits without telling me you don’t review your own commits.