.gitignore排除文件夹,但包含特定的子文件夹 [英] .gitignore exclude folder but include specific subfolder
问题描述
我有添加到.gitignore的文件夹应用程序。应用程序/文件夹内部是文件夹应用程序/语言/ gr。我怎样才能包含这个文件夹?
我试过了这个应用程序/ language / gr /
application /
没有运气......
如果您排除 application /
,那么它下面的所有内容都将被排除(即使稍后的否定排除模式(unignore)可能与 application /
)。
要做你想做的事情,你必须你想要统一。通常你最终会为这种情况成对编写规则:忽略目录中的所有内容,但不包括某些特定的子目录。
#you可以跳过这第一个,如果它没有被先前模式排除的话
!application /
application / *
!application / language /
application / language / *
!application / language / gr /
I have the folder application/ which I add to the .gitignore. Inside the application/ folder is the folder application/language/gr. How can I include this folder?
I've tried this with no luck... If you exclude To do what you want, you have to "unignore" every parent directory of anything that you want to "unignore". Usually you end up writing rules for this situation in pairs: ignore everything in a directory, but not some certain subdirectory. Note 这篇关于.gitignore排除文件夹,但包含特定的子文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
$ b $ ul
使用dir /,Git将永远不会查看dir下的任何内容,因此绝不会将任何un-exclude模式应用于dir下的任何内容。
使用dir / *,Git将处理目录的直接内容,为其他模式提供解除某些内容(!dir / sub /)的机会。
application/
!application/language/gr/
application/
, then everything under it will always be excluded (even if some later negative exclusion pattern ("unignore") might match something under application/
).# you can skip this first one if it is not already excluded by prior patterns
!application/
application/*
!application/language/
application/language/*
!application/language/gr/
The trailing /* is significant:
With dir/, Git will never look at anything under dir, and thus will never apply any of the "un-exclude" patterns to anything under dir.