Search code examples
gitgitattributes

Target files with no file extension in .gitattributes


So, in .gitattributes,* matches all files, including those that have no file extension, and more specific rules can be applied later down in the attributes file.

How should one go about targeting files that have no file extension, i.e., where the file name does not contain a dot, without also applying that rule to every other file and having to explicitly specify rules for those other files further down?


Solution

  • The .gitattributes pattern matching language can't say "all files with no dot in the name" with a single pattern, but you can combine them:

    * -text
    *.* text=auto
    

    and then follow that with any later overrides you already have.

    There's no "pretend this attribute was never set to anything" syntax, you have to set the attribute to something. But for attributes like text where you sometimes really want the default treatment an unspecified value gets you there's always an explicit setting you can give that gets the same result. For text you could use unspecified.