例外子文件夹中的.gitignore
问题描述:
我有一个设置为忽略除特定模式的所有文件,像这样一个混帐回购目录:例外子文件夹中的.gitignore
# ignore all files except for template config files
!/
/*
!exception_dir/
!.gitignore
!init.sh
!blah.template.json
我加入,我想设置例外子目录对于。像这样:
# ignore all files except for template config files
!/
/*
!exception_dir/
!.gitignore
!init.sh
!blah.template.json
!exception2_subdir/
正如所料,上述语法不会忽略'exception2_subdir'内的所有文件。但是,我只想将某些文件添加到exception2_subdir中的git中。我通过谷歌搜索找到以下语法:
# ignore all files except for template config files
!/
/*
!exception_dir/
!.gitignore
!init.sh
!blah.template.json
!exception2_subdir/add_this_template_file_to_git_please
!exception2_subdir/add_this_template_file_to_git_please2
此语法似乎没有工作。当我尝试手动添加'exception2_subdir/add_this_template_file_to_git_please'时,出现错误消息,该路径被我的.gitignore文件忽略。有小费吗?
请注意,这不是我的架构,所以我改变结构的能力有限。
谢谢!
埃里克
答
我需要明确地屏蔽该目录,则忽略该项目录,然后屏蔽特定文件:/
# ignore all files except for template config files
!/
/*
!exception_dir/
!.gitignore
exception_dir/*
!exception_dir/add_this_template_file_to_git_please
!exception_dir/add_this_template_file_to_git_please2
的[排除的.gitignore文件夹,但包括具体的子文件夹(HTTPS可能重复: //stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder) – phd