node.js - git 排除文件夹中除子目录之外的所有内容

标签 node.js git

我正在开发一个 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/

相关文章:

angularjs - 在 Express 和 Angular Controller 中与其他路线共享子进程的结果

javascript - 在 Node.js 中,我如何加载我的模块一次,然后在整个应用程序中使用它们?

html - 忽略 git-diff 中的任何空格或换行符

git - 有没有办法在GIT中锁定一个分支

java - 我项目中的 gitignore apikeys

javascript - Node.js 随机抛出写入 EIO 异常

node.js - 在Windows中从.csv文件将数据导入mongodb数据库

node.js - 如何阅读 Node.js API 文档? e.g. 是什么意思? "stat(2)"是什么意思?

git - 樱桃选择问题 : changes from previous commits are also applied

git - 如何为Windows安装Git Shell?