Git:不要忽略-directory-中有一个点

Wes*_*ley 8 git version-control gitignore

我试过这个.gitignore文件:

 *
 !mydirectory.ext
 !.gitignore
Run Code Online (Sandbox Code Playgroud)

但它不起作用,除了gitignore之外的所有东西都被忽略了.

还尝试过:

 !\mydirectory\.ext
Run Code Online (Sandbox Code Playgroud)

该目录需要扩展,因为它是一个应用程序的插件.

任何解决方法?

小智 8

REF

*
!/mydirectory.ext/
!/mydirectory.ext/*
!/mydirectory/.ext/
!/mydirectory/.ext/*
!.gitignore
Run Code Online (Sandbox Code Playgroud)

要么

*
# ignore all 
!/.*/
# but not directories which names starting with a dot
!/.*/*
# and all its contents
/.*/*/
# but ignore other directories (which names not starting with a dot)
# which results also not tracking its files underneath
!/.*/.*/
# but not to subdirectories (which names starts with a dot)
!/.*/.*/*
# and its contents


!/*.*/
# don't ignore directories which names has a dot in it
!/*.*/*
# and its contents
# extend it like with /.*/ 
!.gitignore
Run Code Online (Sandbox Code Playgroud)

等等


mic*_*has 2

这些白名单在 git 中并不容易实现。

一旦你忽略一个目录,git 将不会查看它的内部,因此不会检查该目录内的异常。

解决这个问题的唯一方法是使用长的包含/排除级联,这真的很难看。

最好的方法是再次考虑您的问题并尝试在没有此类一般例外的情况下解决它,例如明确忽略您确定不想要的所有内容。