

…every file or folder with name #comment ( \ for escaping) …nothing, this is a comment (first character is a #) class recursivelyįor more complicated use cases refer to the following table. … folder named target in the top-most directory (leading and trailing /) … file or folder named target in the top-most directory (due to the leading /) … file or folder named target recursively … folder (due to the trailing /) recursively Here is an overview of the most relevant patterns. This means we don’t even need any * at all. This will match any directory (but not files, hence the trailing /) in any subdirectory relative to the. The Most Important Use Casesįirst things first, how can we exclude every target folder created by Maven in every sub-module?

Don’t worry, you don’t need to read the fnmatch(3) documentation, simply refer to the tables in the next sections. If only people would read this before posting to Stackoverflow…Īs it turns out Git does not use regex, nor wildcards, nor Ant-style syntax, but unix glob patterns (specifically those valid for fnmatch(3)). The official Git documentation on gitignore:

So how exactly can we specify which files to exclude? Can we use Ant-style syntax like **/*, simple Wildcards *target or even Regex ? The Truth We simply don’t want to version control everything, especially generated files like Maven’s target or Gradle’s build folder. gitignore allows? Was it **/*/target, target/* or *target*? Read on and find out! MotivationĮveryone who uses Git sooner or later has to define a. Have you ever wondered what kind of patterns.
