I have a file structure similar to the one below:
foo/bar.foo
node_modules/foo/bar.json
node_modules/foo/bar/foo.bar
What I want to do is ignore all the files inside the node_modules
folder except the json
files so that I end up with the following file structure in my repo:
foo/bar.foo
node_modules/foo/bar.json
I tried to find a simple way to do that but I'm not quite there yet.
Here's what I came up with in my .gitignore
:
# ignore everything inside node_modules
node_modules/*
# But descend into directories
!node_modules/**/*.json
What's the most elegant way to achieve the desired result?
P.S. I have no idea what I'm doing.