pack a folder without some files
Make a tar archive of a folder, leaving out folders like node_modules and files like logs.
Steps
-
tar -czf project.tar.gz --exclude='node_modules' --exclude='*.log' project/pack project without node_modules and the logs
-
tar -czf project.tar.gz --exclude-vcs project/without .git and the like (GNU tar)
-
tar -tzf project.tar.gz | lesscheck what went in
-
git archive -o project.tar.gz HEADin a git repository: only the files git tracks
Notes
- Put the --exclude options before the folder: some tar versions ignore them after it.
Commands used
targit
Each has a page in lore: lore tar opens it.
Related recipes
- compress a folderPack a folder into one compressed file, look inside it, and unpack it again.
- unpack an archiveOpen any common archive: tar, zip, gz, xz, 7z, rar.
- add to the end of a fileAdd lines to a file without replacing it, also to a file only root can write.
- argument list too long"Argument list too long" from rm, cp or mv: too many files for one command line. Hand them over in batches.