Skip to the content.

Tar Exclude Directories

To exclude a directory while making a tar file, we can pass --exclude="" argument to tar command.

Example

$ tar czf {FILE_NAME}.tar.gz --exclude=".git" --exclude=".github" ./

Here, .git and .github directory would be excluded; not included in the tar file.

Source: StackOverFlow