1

What would be the format for excluding files that do not have an extension, such as runme, which does not have an extension. For example, if the files in my directory are:

script.sh
script.s
runme

I want to exclude the files without an extension. I suppose the regex for this would be ^[^.]+$. How does this go into a .gitignore though? What are the regex (or is it more unix/shell filepath matching patterns)?

samuelbrody1249
  • 4,379
  • 1
  • 15
  • 58
  • 1
    Please refer to this Q/A: https://stackoverflow.com/questions/5711120/gitignore-without-binary-files/25592735 – Veikko Aug 26 '20 at 05:22

1 Answers1

1

The gitignore file format doesn't support regular expressions, just regular Unix-style patterns.

In your case, I would exclude everything and then allow the files that do have an extension. For example:

# Ignore everything
*
# Allow directories
!*/
# Allow files with an extension
!*.*

This would include files like these:

foo.txt
some/dir/bar.txt

But exclude files like these:

foo
some/dir/bar
Enrico Campidoglio
  • 56,676
  • 12
  • 126
  • 154