子文件夹的 .gitignore 应该覆盖
Subfolder's .gitignore should override
我有一个树结构如下所示的项目:
+ /Root
- .gitignore
+ - - /Folder A
- - - .gitignore <--- this fellow
+ - - - /bin
- - - - - fileA
+ - - - - fileB
+ - - - /Folder AA
+ - - /FolderB
+ - - - /bin
...
根文件夹中的.gitignore
有很多规则,其中就是忽略所有/bin
文件夹。
但是,在我的 FolderA
中,我希望所有内容都保持原样 - 一直在 that 文件夹中。
FolderB/bin
另一方面应该被忽略。
我知道这可以通过在 FolderA
中添加另一个 .gitignore
来实现,并让它覆盖根文件夹的 .gitignore
。但是我不记得了。
我应该在FolderA/.gitignore
中写什么?
编辑:
换句话说:"FolderA
是一个神圣的文件夹,必须将其中的所有文件都保留在其中,而不管其他 .gitignore
-文件必须说什么"
使用包含语法覆盖 /FolderA/.gitignore
中的根 .gitignore
:
!file_that_should_not_be_ignored
!folder_that_should_not_be_ignored
找到的解决方案:
在需要排除的文件夹中添加的.gitignore
文件中,仅添加如下一行:
!*/
我有一个树结构如下所示的项目:
+ /Root
- .gitignore
+ - - /Folder A
- - - .gitignore <--- this fellow
+ - - - /bin
- - - - - fileA
+ - - - - fileB
+ - - - /Folder AA
+ - - /FolderB
+ - - - /bin
...
根文件夹中的.gitignore
有很多规则,其中就是忽略所有/bin
文件夹。
但是,在我的 FolderA
中,我希望所有内容都保持原样 - 一直在 that 文件夹中。
FolderB/bin
另一方面应该被忽略。
我知道这可以通过在 FolderA
中添加另一个 .gitignore
来实现,并让它覆盖根文件夹的 .gitignore
。但是我不记得了。
我应该在FolderA/.gitignore
中写什么?
编辑:
换句话说:"FolderA
是一个神圣的文件夹,必须将其中的所有文件都保留在其中,而不管其他 .gitignore
-文件必须说什么"
使用包含语法覆盖 /FolderA/.gitignore
中的根 .gitignore
:
!file_that_should_not_be_ignored
!folder_that_should_not_be_ignored
找到的解决方案:
在需要排除的文件夹中添加的.gitignore
文件中,仅添加如下一行:
!*/