我正在创建一个节点js项目,并且正在创建一个节点模块,现在要将它添加到我正在处理的项目中。所以在我的gitignore我把下面的,但它没有工作git排除子目录以外的文件夹中的所有内容
node_modules/*
!node_modules/zephyr-rest
西风,剩下的就是一个目录,所以我想只是为了保存该目录及其文件。我不希望node_modules下的任何其他子目录被版本化。谢谢
我正在创建一个节点js项目,并且正在创建一个节点模块,现在要将它添加到我正在处理的项目中。所以在我的gitignore我把下面的,但它没有工作git排除子目录以外的文件夹中的所有内容
node_modules/*
!node_modules/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_modules/zephyr-rest /'也许吧? – jgillich
这篇文章可能会帮助你:http://stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder – Ben