2014-07-16 48 views
0

我正在创建一个节点js项目,并且正在创建一个节点模块,现在要将它添加到我正在处理的项目中。所以在我的gitignore我把下面的,但它没有工作git排除子目录以外的文件夹中的所有内容

node_modules/* 
!node_modules/zephyr-rest 

西风,剩下的就是一个目录,所以我想只是为了保存该目录及其文件。我不希望node_modules下的任何其他子目录被版本化。谢谢

+0

'!node_modules/zephyr-rest /'也许吧? – jgillich

+0

这篇文章可能会帮助你:http://stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder – Ben

回答

2

试试这个,为我工作。

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/

+0

这是什么git状态显示我改变后 在分支主 更改没有上演承诺: (使用“混帐添加 ...”更新的内容将被提交) (使用“git的结帐 - ...”丢弃在工作目录的变化) \t修改:的.gitignore \t修改:routes/index.js 未被跟踪的文件: (使用“git add ...”来包含将被提交的内容) \t node_modules/ 没有更改添加到提交(使用“git add”和/或“git commit -a”) – jrock2004

+0

所以它应该工作。 – Mritunjay

+0

但它没有显示zephyr-rest文件夹 – jrock2004

相关问题