0

My gitignore file looks like this:

*.csv
*.dat
*.iml
*.log
*.out
*.pid
*.seed
*.sublime-*
*.swo
*.swp
*.tgz
*.xml
.DS_Store
.idea
.project
.strong-pm
coverage
node_modules
npm-debug.log
server-info
definitions/

Yet, suddenly git status shows me a lot of npm-debug.log files in red. enter image description here

I also get the message

nothing added to commit but untracked files present (use "git add" to track)

How do I remove all the npm-debug.log files from my local machine without accidentally deleting any important files?

Also, how do I prevent these files from being created in the first place?

VK1
  • 1,676
  • 4
  • 28
  • 51

2 Answers2

2

To ignore the npm-debug files on Git you're missing a star at the end of the string in your .gitignore file.

npm-debug.log*

And if you want to never generate those logs, you can execute the install with --loglevel=silent, anyway I don't recommend to do that, they may be useful.

d4vsanchez
  • 1,904
  • 1
  • 14
  • 24
  • Thanks for responding. I'm taking your advice and will NOT use --loglevel=silent. – VK1 Jul 01 '19 at 06:42
1

You need to add npm-debug.log* to your .gitignore file, because the current status of the .gitignore file means npm-debug.log only.

Adding asterisk * will ensure that any file starting with npm-debug.log will be ignored

If you want to delete them forever from your machine use the following command:

rm -f npm-debug.log.*
Mostafa Hussein
  • 11,063
  • 3
  • 36
  • 61