-1

I usually put /node_modules in my .gitignore file.

# .gitignore

/node_modules

But this time, I would like to include one specific node_modules-package in my git version control.

I.e when I commit and push to remote, the node_modules folder should be included, but all modules inside it are gone, except my-package under the organization @my-organization. I.e:

/node_modules
    /@my-organization
        /my-package
            /<files and folders>

How can I modify my .gitignore to accomplish this?

johann1301s
  • 343
  • 4
  • 19

1 Answers1

0
# .gitignore

!node_modules

node_modules/*
!node_modules/@my-organization/

node_modules/@my-organization/*
!node_modules/@my-organization/my-package/

johann1301s
  • 343
  • 4
  • 19
  • 1
    Remember that Stack Overflow isn't just intended to solve the immediate problem, but also to help future readers find solutions to similar problems, which requires understanding the underlying code. This is especially important for members of our community who are beginners, and not familiar with the syntax. Given that, **can you [edit] your answer to include an explanation of what you're doing** and why you believe it is the best approach? – Jeremy Caney Nov 10 '22 at 00:17