子文件夹文件夹中的.gitignore异常

时间:2017-10-20 16:58:24

标签: git

我在git repo中有一个目录,设置为忽略除某些模式之外的所有文件:

# ignore all files except for template config files
!/

/*
!exception_dir/
!.gitignore
!init.sh
!blah.template.json
!exception2_subdir/

我添加了一个我想为其设置例外的子目录。像这样:

# 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'中的所有文件。但是,我只想在exception2_subdir中添加到git的某些文件。我通过谷歌搜索找到了以下语法:

DOG

此语法似乎不起作用。当我尝试手动添加'exception2_subdir / add_this_template_file_to_git_please'时,我收到错误消息,即我的.gitignore文件忽略了该路径。有什么提示吗?

请注意,这不是我的架构,所以我改变结构的能力有限。

谢谢!

埃里克

1 个答案:

答案 0 :(得分:0)

我需要显式取消dir,然后忽略dir,然后取消特定文件:/

# 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
相关问题