【问题标题】: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)"npm-debug.log 在 .gitignore 文件中,但我仍然收到消息“没有添加到提交但存在未跟踪的文件(使用“git add”进行跟踪)”
【发布时间】:2019-07-01 06:05:58
【问题描述】:

我的 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/

然而,突然git status 向我显示了许多红色的 npm-debug.log 文件。

我也收到消息了

没有添加到提交但存在未跟踪的文件(使用“git add” 跟踪)

如何在不意外删除任何重要文件的情况下从本地计算机中删除所有 npm-debug.log 文件?

另外,我如何防止这些文件被创建?

【问题讨论】:

    标签: git logging npm-debug


    【解决方案1】:

    要忽略 Git 上的 npm-debug 文件,您会在 .gitignore 文件中的字符串末尾缺少一个星号。

    npm-debug.log*

    如果您不想生成这些日志,可以使用--loglevel=silent 执行安装,无论如何我不建议这样做,它们可能有用。

    【讨论】:

    • 感谢您的回复。我正在听取您的建议,不会使用 --loglevel=silent。
    【解决方案2】:

    您需要将npm-debug.log* 添加到您的.gitignore 文件中,因为.gitignore 文件的当前状态仅表示npm-debug.log

    添加星号* 将确保任何以npm-debug.log 开头的文件都将被忽略

    如果您想从您的机器中永久删除它们,请使用以下命令:

    rm -f npm-debug.log.*
    

    【讨论】:

      猜你喜欢
      • 2016-02-04
      • 2021-02-24
      • 2016-10-29
      • 2017-12-30
      • 2018-07-21
      • 2017-10-04
      • 2011-03-27
      • 1970-01-01
      • 2022-01-27
      相关资源
      最近更新 更多