Ignore Directory In All Subdirectories from .gitignore

Syntax

These syntaxes will ignore directory matches across ALL subdirectories.

dir_ignored
dir_ignored/
**/dir_ignored/

Example:

In the following example ALL files will be ignored, with either of the above syntax.

.
├── dir_ignored
│   ├── f1.txt
│   └── subdir-in-ignored
│       └── f2.txt
└── subdir-in-top
    └── dir_ignored
        └── f3.txt

4 directories, 3 files

Clarification

Must match directory exactly

The syntax that we used here must match directory exactly.

For example if we add suffix to directory name it WILL not match:

.
├── dir_ignored
│   └── gets-ignored.txt
└── dir_ignored_2
    └── i-am-not-ignored.txt

2 directories, 2 files

Backlinks