Skip to content

Instantly share code, notes, and snippets.

@encoreshao
Created November 12, 2017 10:10
Show Gist options
  • Save encoreshao/e62795f0c2e2d549f40b765d93711e92 to your computer and use it in GitHub Desktop.
Save encoreshao/e62795f0c2e2d549f40b765d93711e92 to your computer and use it in GitHub Desktop.
Zip excluding specific directories
## Zip excluding specific directories
Exclude *.git* file and *node_modules* directory
$ zip -r9 [target_file] [source_file] -x *.git* node_modules/\*
Exclude *.git* file and files in *node_modules* directory, but keep *node_modules* directory
$ zip -r9 [target_file] [source_file] -x *.git* node_modules/**\*
Number parameter means degree of compression. `-9` is the most optimal but the slowest compression. If `-0` is given, there will be no compression. Default level is `-6`.
`**` means to adapt exclusions recursively inner directories. `\*` is an escaped wildcard to avoid path expansion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment