简体   繁体   English

npm-debug.log位于.gitignore文件中,但我仍然收到消息“没有添加任何内容来提交但存在未跟踪的文件(使用” git add”进行跟踪)”

[英]npm-debug.log is in .gitignore file, but I still get the messsage “nothing added to commit but untracked files present (use ”git add“ to track)”

My gitignore file looks like this: 我的gitignore文件如下所示:

*.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. 但是,突然git status向我显示了很多红色的npm-debug.log文件。 在此处输入图片说明

I also get the message 我也收到消息

nothing added to commit but untracked files present (use "git add" to track) 没有添加任何内容提交但存在未跟踪的文件(使用“ git add”进行跟踪)

How do I remove all the npm-debug.log files from my local machine without accidentally deleting any important files? 如何从本地计算机上删除所有npm-debug.log文件,而又不小心删除任何重要文件?

Also, how do I prevent these files from being created in the first place? 另外,如何防止首先创建这些文件?

You need to add npm-debug.log* to your .gitignore file, because the current status of the .gitignore file means npm-debug.log only. 您需要添加npm-debug.log*.gitignore文件,因为当前状态.gitignore文件意味着npm-debug.log只。

Adding asterisk * will ensure that any file starting with npm-debug.log will be ignored 添加星号*将确保以npm-debug.log开头的任何文件都将被忽略

If you want to delete them forever from your machine use the following command: 如果要从计算机上永久删除它们,请使用以下命令:

rm -f npm-debug.log.*

To ignore the npm-debug files on Git you're missing a star at the end of the string in your .gitignore file. 要忽略Git上的npm-debug文件,您需要在.gitignore文件中的字符串末尾缺少星号。

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. 而且,如果您不希望生成那些日志,则可以使用--loglevel=silent执行安装,无论如何,我不建议这样做,它们可能会很有用。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Git:没有添加任何提交但存在未跟踪的文件 - Git:nothing added to commit but untracked files present Git 没有向提交添加任何内容,但存在未跟踪的文件 - 即使将这些文件添加到 gitignore - Git nothing added to commit but untracked files present - even with those files added to gitignore Git-列出根目录中的每个文件后,“没有添加任何内容来提交但存在未跟踪的文件” - Git - “nothing added to commit but untracked files present” after listing every file in root git 添加。 -> 新文件仍然“没有什么可提交的” - git add . -> still "nothing to commit" with new files Git跟踪未跟踪的文件而不添加提交 - Git track untracked files without adding to commit 在 Branch master git status 上没有显示要提交的内容(创建/复制文件并使用“git add”进行跟踪) - On Branch master git status is showing nothing to commit (create/copy files and use "git add" to track) 如何让git根据.gitignore(从一开始)来跟踪和提交文件? - How do I get git to track and commit files according to .gitignore (from the beginning)? Git 无法正常工作,无需提交(创建/复制文件并使用“git add”进行跟踪) - Git not working properly nothing to commit (create/copy files and use “git add” to track) 尽管.gitignore和rm -r --cached,git仍然显示文件未跟踪。 我做错了什么? - git still shows files as untracked despite .gitignore and rm -r --cached. What did I do wrong? 为什么git仍然跟踪已经添加到.gitignore文件的扩展名的文件 - Why is git still tracking files with extensions already added to .gitignore file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM