NetBeans 8.2和Git:如何从忽略文件或目录中排除。供应商目录默认被忽略

问题描述:

我有Netbeans 8.2,你可以看到我有两个文件在我的项目中被正确忽略,这些文件是“.gitkeep”和“app.properties”。但是我想排除忽略/ vendor/Demo/librery/File目录下的所有文件,但是我不得不做一些事情,因为我没有看到它们的变化。NetBeans 8.2和Git:如何从忽略文件或目录中排除。供应商目录默认被忽略

enter image description here

的.gitignore文件:

.vagrant/ 
vendor/* 
vendor/bin/* 
vendor/composer/* 
vendor/container-interop/* 
vendor/psr/* 
vendor/zendframework/* 
vendor/zfcampus/* 
!vendor/Demo/* 
config/development.config.php 
data/cache/* 
data/logs/* 
!data/cache/.gitkeep 
phpunit.xml 
ubuntu-xenial-16.04-cloudimg-console.log 

我在做什么错?

编辑1:

我已经在我的.gitignore文件中的一些变化和它不工作。

的.gitignore文件:

.vagrant/ 
vendor/bin/* 
vendor/composer/* 
vendor/container-interop/* 
vendor/psr/* 
vendor/zendframework/* 
vendor/zfcampus/* 
!vendor/Demo/* 
config/development.config.php 
data/cache/* 
data/logs/* 
!data/cache/.gitkeep 
phpunit.xml 
ubuntu-xenial-16.04-cloudimg-console.log 

编辑2:

更多的变化和它不工作。

.vagrant/ 
!vendor/ 
vendor/bin/* 
vendor/composer/* 
vendor/container-interop/* 
vendor/psr/* 
vendor/zendframework/* 
vendor/zfcampus/* 
!vendor/Demo/* 
config/development.config.php 
data/cache/* 
data/logs/* 
!data/cache/.gitkeep 
phpunit.xml 
ubuntu-xenial-16.04-cloudimg-console.log 

编辑3:

为什么厂商会被忽略?

.vagrant/ 
#!vendor/ 
#vendor/bin/* 
#vendor/composer/* 
#vendor/container-interop/* 
#vendor/psr/* 
#vendor/zendframework/* 
#vendor/zfcampus/* 
#!vendor/Demo/* 
config/development.config.php 
data/cache/* 
data/logs/* 
!data/cache/.gitkeep 
phpunit.xml 
ubuntu-xenial-16.04-cloudimg-console.log 

enter image description here

固定它!

给予我的所有解决方案都是正确的。 NetBeans的问题在于,您必须关闭NetBeans,清理NetBeans的缓存文件夹,最后再次打开NetBeans以查看以前在.gitignore文件中所做的更改。

+0

拿!从行前。 app.properties甚至没有列出。 – aynber

+0

不起作用。我想从ignor/vendor/Demo/*中排除。如果我拿出“!”我不是无视,不是吗? –

+1

Git忽略.gitignore文件中列出的所有内容。检查这里的文档:https://git-scm.com/docs/gitignore还要确保文件名为.gitignore,而不是.ignore – aynber

但我想从忽略所有那些/vendor/Demo/library/File目录下的文件排除,

拳忽略供应商的内容,而不是供应商本身(文件夹)。
这是因为:It is not possible to re-include a file if a parent directory of that file is excluded.

/vendor/* 

无需其他所有vendor/xxx这里的规则。

然后排除那些无视规则的文件夹:

!/vendor/**/ 

最后,排除您需要的文件:

!/vendor/Demo/library/File/** 

你应该关闭这里

“从版本忽略 vendor文件夹”

enter image description here

和“P永久忽略不可共享“这里

enter image description here