Angular + Git - How to Include a file from a package exists inside node_modules

Viewed 92

I have ng-payment-card package and I've made some modifications in a file inside the package, and I need to include this file in the git commit in order to not reset it every time I make npm install.

I tried to write in .gitignore like this:

!/node_modules/ng-payment-card/__ivy_ngcc__/fesm2015/ng-payment-card.js

but the same, the file hasn't been added to the commit.

2 Answers

Even if the file is currently ignored, you can force adding it:

git add --force  node_modules/ng-payment-card/__ivy_ngcc__/fesm2015/ng-payment-card.js

That way, everything else remains ignored, while your file becomes tracked.

if you like to work with .gitignore

thats what you need to add to .gitignore

/*

!node_modules

node_modules/*

!node_modules/ng-payment-card

node_modules/ng-payment-card/*

!node_modules/ng-payment-card/ivy_ngcc

node_modules/ng-payment-card/ivy_ngcc/*

!node_modules/ng-payment-card/ivy_ngcc/fesm2015

node_modules/ng-payment-card/ivy_ngcc/fesm2015/*

!node_modules/ng-payment-card/ivy_ngcc/fesm2015/ng-payment-card.js

basically the problem is you have to allow access to all the sub directories to get to the last folder where the file is residing.

Related