0

i have a repo where the files inside node_modules are also committed to the repo. i need to perform a git diff on the repo but want to ignore everything under node_modules. how can i do this?

i tried this git diff old_api..master -- . ':!node_modules' (as suggested in this answer: https://stackoverflow.com/a/29374503) but it still diffs the content inside node_modules directory, e.g.:

diff --git a/db/node_modules/bhttp/README.md b/db/node_modules/bhttp/README.md

also i'm not sure what the .. does so i removed it and tried this: git diff old_api master -- . ':!node_modules' but no difference.

any help?

Community
  • 1
  • 1
Shikasta_Kashti
  • 701
  • 2
  • 13
  • 28

2 Answers2

0

I am new to git but in the past I have cleared the cache on git and then added a .gitignore with the node module pathway included.

Here is a sample cache command:

git rm -r --cached .
git add .
git commit -am 'git cache cleared'
git push

Here is some documentation to get you started: git ignore docs

There are also many templates around git hubs to get you started with a boilerplate .gitignore here is a link to many excellent gitignore files

BatsAuto
  • 79
  • 2
  • 9
  • That's okay if you clear the cache and create a properly written .gitignore file things will sort out. By that I mean they will become removed from the repository – BatsAuto Sep 11 '16 at 19:52
0

Have you tried git diff -- . ':!{path to your node_modules}/node_modules' ?

e.g.: git diff -- . ':!myfolder/anotherfolder/node_modules'

toffi9
  • 89
  • 5