> For the complete documentation index, see [llms.txt](https://til.devjugal.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://til.devjugal.com/linux/tar-exclude-directories.md).

# Tar Exclude Directories

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

## Example

```bash
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***](https://stackoverflow.com/questions/984204/shell-command-to-tar-directory-excluding-certain-files-folders)
