Git 除一种文件类型外忽略
Git ignore except one file type
我有一个忽略 bin 文件夹的规则(构建结果):
[Bb]in/
我希望 git 仍然添加所有 .txt 文件,甚至是 bin 目录中的文件(但忽略该目录中的所有其他内容)。我怎样才能做到这一点?
[Bb]in/*
!*.txt
此模式应该能为您找到答案。如果你在一个模式之前加上否定(!
),它被标记为不可忽略,不管它上面的所有忽略。
参考 - https://www.atlassian.com/git/tutorials/gitignore
引用自https://git-scm.com/docs/gitignore#_pattern_format
It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so ...
我有一个忽略 bin 文件夹的规则(构建结果):
[Bb]in/
我希望 git 仍然添加所有 .txt 文件,甚至是 bin 目录中的文件(但忽略该目录中的所有其他内容)。我怎样才能做到这一点?
[Bb]in/*
!*.txt
此模式应该能为您找到答案。如果你在一个模式之前加上否定(!
),它被标记为不可忽略,不管它上面的所有忽略。
参考 - https://www.atlassian.com/git/tutorials/gitignore
引用自https://git-scm.com/docs/gitignore#_pattern_format
It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so ...