忽略特定目录中的所有内容,但排除忽略目录中的某些文件
Ignore everything in a specific directory but exclude some files in the ignored directory
在我的 git 存储库中,我有几个目录。我完全忽略了许多目录中的一个。但我想排除(白名单)嵌套在该目录中的单个文件。像这样
!*/Databases/
!Databases/Links_Databases.txt
!Databases/AFLW/README.txt
这里第二行可以,第三行不行。嵌套的 README.txt 文件仍然被忽略。我怎样才能将该文件列入白名单?
我在这里找到的答案很少:One, two and three。但是这里提供的解决方案忽略了根目录中的所有内容。我将不得不手动将我想要包含的其他目录列入白名单。所以,它没有达到我的目的。
最好,我只想编辑我的 gitignore 主文件。如果没有其他办法,我可以在子目录中创建另一个 gitignore。
您必须'unignore'文件所在的目录:
# Ignore all contents of Databases directory
Databases/*
# Except this direct child file
!Databases/Links_Databases.txt
# And the relevant subdir
!Databases/AFLW/
# Ignore all contents in subdir
Databases/AFLW/*
# Except this file we want to keep
!Databases/AFLW/README.txt
虽然它不是严格意义上的重复,但这里的答案中有一个非常相似的问题并且有很好的解释:.gitignore exclude folder but include specific subfolder
在我的 git 存储库中,我有几个目录。我完全忽略了许多目录中的一个。但我想排除(白名单)嵌套在该目录中的单个文件。像这样
!*/Databases/
!Databases/Links_Databases.txt
!Databases/AFLW/README.txt
这里第二行可以,第三行不行。嵌套的 README.txt 文件仍然被忽略。我怎样才能将该文件列入白名单?
我在这里找到的答案很少:One, two and three。但是这里提供的解决方案忽略了根目录中的所有内容。我将不得不手动将我想要包含的其他目录列入白名单。所以,它没有达到我的目的。
最好,我只想编辑我的 gitignore 主文件。如果没有其他办法,我可以在子目录中创建另一个 gitignore。
您必须'unignore'文件所在的目录:
# Ignore all contents of Databases directory
Databases/*
# Except this direct child file
!Databases/Links_Databases.txt
# And the relevant subdir
!Databases/AFLW/
# Ignore all contents in subdir
Databases/AFLW/*
# Except this file we want to keep
!Databases/AFLW/README.txt
虽然它不是严格意义上的重复,但这里的答案中有一个非常相似的问题并且有很好的解释:.gitignore exclude folder but include specific subfolder