1

I was going through the answers of How do I add files without dots in them (all extension-less files) to the gitignore file?

One answer is:

*
!/**/
!*.*

and the other answer is:

*
!*/
!*.*

So, is there any difference between !/**/ and !*/ or are they similar.

Ahmad Ismail
  • 11,636
  • 6
  • 52
  • 87

1 Answers1

0

Since I wrote the original answer (in 2013), I believe my intent was to anchor the exclusion at the top folder '/' (where the .gitignore is), with the special format:

A trailing "/**" matches everything inside. For example, "abc/**" matches all files inside directory "abc", relative to the location of the .gitignore file, with infinite depth.

Meaning I want to exclude all folders (**/) starting from the top (/: inside top folder).

That is a more complex way to write */ with:

  • '*': match anything (except '/') at any depth
  • '/': match only folders (which ends with '/')

In both instances, the idea remains:

  • ignore everything
  • except folders
  • then except dot files
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250