覆盖子文件夹中的 gitignore
override gitignore in subfolder
考虑以下文件结构:
根文件夹
- .gitignore
- 子文件夹
- 距离
- .gitignore(忽略 dist 文件夹)
子文件夹中的 .gitignore 忽略了 dist 文件夹。有什么方法可以通过编辑 RootFolder 中的 .gitignore 来包含 dist 文件夹?
我有 20 个具有相同 .gitignore 的子文件夹,如果我能够做到这一点,而不是进入每个子文件夹并手动编辑 gitignore 以包含 dist 文件夹,那就太好了。
The .gitignore
in the SubFolder
is ignoring the dist
folder. Is there any way I can include the dist
folder by editing the .gitignore
in the RootFolder
?
我首先误解了那部分,认为它完全相反。要回答这个问题:不,这不可能。
子目录中的 Gitignore 文件将始终比父目录中的文件具有更高的优先级。这样做是为了允许根目录中的通用规则可以被子目录中更具体的规则覆盖。
然而,您可以做的是简单地删除子目录中的所有 .gitignore
文件。既然你提到它们无论如何都是一样的,你可以完全删除它们并将仍然相关的规则放在根的 .gitignore
.
中
考虑以下文件结构:
根文件夹
- .gitignore
- 子文件夹
- 距离
- .gitignore(忽略 dist 文件夹)
子文件夹中的 .gitignore 忽略了 dist 文件夹。有什么方法可以通过编辑 RootFolder 中的 .gitignore 来包含 dist 文件夹?
我有 20 个具有相同 .gitignore 的子文件夹,如果我能够做到这一点,而不是进入每个子文件夹并手动编辑 gitignore 以包含 dist 文件夹,那就太好了。
The
.gitignore
in theSubFolder
is ignoring thedist
folder. Is there any way I can include thedist
folder by editing the.gitignore
in theRootFolder
?
我首先误解了那部分,认为它完全相反。要回答这个问题:不,这不可能。
子目录中的 Gitignore 文件将始终比父目录中的文件具有更高的优先级。这样做是为了允许根目录中的通用规则可以被子目录中更具体的规则覆盖。
然而,您可以做的是简单地删除子目录中的所有 .gitignore
文件。既然你提到它们无论如何都是一样的,你可以完全删除它们并将仍然相关的规则放在根的 .gitignore
.