使用 zip 时如何排除 .git 目录和 node_modules 目录?

How can I exclude both the .git directories and the node_modules directory when using zip?

我想将当前目录的所有内容压缩到一个 zip 文件中。 在执行此操作时,我想同时排除 .git 目录和 node_modules 目录。

这些命令将排除 .git 目录,但无法排除 node_modules:

zip -r output.zip . -x '*.git*' -x 'node_modules'

zip -r output.zip . -x '*.git*' 'node_modules'

请将您的命令调整为:

zip -r output.zip . -x '*.git*' -x '*node_modules*'