gitignore - !/**/ 和 !*/ 之间有什么区别吗

gitignore - is there any difference between !/**/ and !*/

我正在查看 How do I add files without dots in them (all extension-less files) to the gitignore file?

的答案

一个答案是:

*
!/**/
!*.*

另一个答案是:

*
!*/
!*.*

那么,!/**/!*/有什么不同或者相似吗

自从我写了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.

意思是我想从顶部开始排除所有 文件夹 (**/)(/:在顶级文件夹内)。

这是一种更复杂的 */ 写法:

  • '*':匹配任意深度的任何内容('/'除外)
  • '/':仅匹配文件夹(以'/'结尾)

在这两种情况下,想法仍然是:

  • 忽略一切
  • 文件夹除外
  • 然后 除了点文件