Josh Brunton
Josh Brunton

Reputation: 546

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?

Upvotes: 0

Views: 70

Answers (2)

jthill
jthill

Reputation: 60605

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.

Upvotes: 2

Raul Perez
Raul Perez

Reputation: 1

Write the name of the file "as is". E.g. if your file is called data1, you can write data1 in the .gitignore file.

Upvotes: 0

Related Questions