gitignore文档中的这句话怎么理解了?

If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore file itself. Otherwise the pattern may also match at any level below the .gitignore level.

https://git-scm.com/docs/gitignore

阅读 2.2k
1 个回答

简单的说,就是当 .gitignore 中配置的路径有 / 开头时,就会从 .gitignore 文件的位置匹配,当没有时,就会在子目录中也匹配。

D:.
├─package-a
│  ├─package-aa
│  │  └─_vendor
│  └─_vendor
└─_vendor
  • .gitignore 无内容下 add

image.png

  • .gitignore 内容为 _vendor 时 add

image.png

  • .gitignore 内容为 /_vendor 时 add

image.png

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题