Nonono. This makes sense.
It ignores all other gitignore files in all subdirectories.
It would be one way to enforce concentrating all ignores into this file (or its ancestors).
Had a quick playaround with it:
- Yes, that does prevent gitignore files from being committed.
- It does not prevent locally-created gitignore files from being applied.
But I’d say the latter is overall a good thing, as some build tools will do a
echo "*" > build/.gitignoreto have their build-folder add itself to the ignore-list.Ooh, uncomittable files are still honoured. That’s mildly interesting, I can see it being both useful and maddening.
Does it prevent the initial .gitignore from being commited too?
For example, what if a file name had sensitive information. It’s bad practice, but someone might want to ignore the file while also hiding the ignore rule itself.
/test/fake-person-first-last.json /test/real-person-first-last.jsonSomeone might want to selectively omit the second file while keeping the first, but not show what they are hiding.
.gitignore doesn’t prevent things from being committed. It just tells git to ignore files that aren’t already being tracked. And you can easily override that with
-f. Putting.gitignoreinside of .gitignore will ignore itself (if it’s not already tracked).
What’s the benefit of scripting the wildcard gitignore over just adding build/ to the root gitignore? I guess being build directory name agnostic?
Well, if you’re the build tool that creates that build-folder, then it just means you don’t need to bother your user with adding it to the root gitignore.
One time, I implemented it for basically a repo-specific download cache folder. Ideally, my users don’t need to know of that folder at all.
Or recently, I implemented it for a build tool where my users might not be devs. They might not use Git at all, or not be very adept at it, so I’m glad to not need to document it…
funnily enough I did that and sometimes do in some projects in order to locally not commit IDE stuff or test folders.
if I want to update the .gitignore in such cases I test local and change in the remote.
FYI there is a command to ignore specific files locally:
git update-index --skip-worktree <file_name>from here. And you can later unignore it with--no-skip-worktreeOut of curiousity, I searched about it. Turned out, there were actually people who wanted to ignore the gitignore file. https://stackoverflow.com/questions/10176875/add-gitignore-to-gitignore



