What other wildcard patterns exist?

QuestionsQuestions8 SkillsProDec, 25 2025
0138

Great question! Besides the basic asterisk *, Git uses several other "glob" patterns to help you match files precisely.

Here are the most common wildcard patterns you can use in your .gitignore:

1. The Single Asterisk (*)

Matches zero or more characters within a single directory level.

  • *.txt matches notes.txt and todo.txt.
  • res* matches results.txt or resources/.

2. The Double Asterisk (**)

Matches directories recursively (at any depth).

  • **/logs/ matches a directory named logs anywhere in the project (e.g., logs/, scripts/logs/, or src/assets/logs/).
  • docs/**/*.pdf matches all PDF files inside the docs folder and any of its subfolders.

3. The Question Mark (?)

Matches exactly one character.

  • file?.txt matches file1.txt or fileA.txt, but it will not match file10.txt.

4. Square Brackets ([ ])

Matches a single character from a specific set.

  • temp[0-9].txt matches temp0.txt through temp9.txt.
  • data[ab].csv matches dataa.csv and datab.csv, but not datac.csv.

5. Range within Brackets ([ - ])

Used inside square brackets to define a range.

  • [a-z].log matches any single lowercase letter log file.

Summary Table:

Pattern Meaning Example
* Zero or more characters *.log
? Exactly one character test?.py
[abc] Any one character inside brackets v[123].js
** Nested directories **/output/

In your current lab, you've used the most common one (*). As your projects grow more complex, these other patterns will help you keep your repository clean

0 Comments

no data
Be the first to share your comment!