我正在开发一个 Node js 项目,并且正在创建一个 Node 模块,目前希望将其添加到我正在开发的项目中。所以在我的 gitignore 中我输入了以下内容,但它不起作用
node_modules/*
!node_modules/zephyr-rest
zephyr-rest 是一个目录,所以我只想保存该目录及其文件。我不希望对 node_modules 下的任何其他子目录进行版本控制。谢谢
最佳答案
试试这个,对我有用。
node_modules/*
!node_modules/zephyr-rest/
在git status
之后它将显示如下
Untracked files:
(use "git add <file>..." to include in what will be committed)
node_modules/
不用担心,因为git status
只是告诉最顶层的未跟踪文件夹为untracked
而不是每个子文件夹,所以这表明有一个未跟踪的文件夹node_modules
。执行 git add node_modules
应该只添加 node_modules/zephyr-rest/
关于node.js - git 排除文件夹中除子目录之外的所有内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24781396/