1

I have Netbeans 8.2 and as you can see I have two files ignored correctly in my project, these files are ".gitkeep" and "app.properties". But I want to exclude from ignore all the files that are under /vendor/Demo/librery/File directory, but I have to do something wront because I don't see their changes.

enter image description here

.gitignore file:

.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

What am I doing wrong?

Edit 1:

I have made some changes in my .gitignore file and it doesn't work.

.gitignore file:

.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

Edit 2:

More changes and it doesn't work.

.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

Edit 3:

Why vendor is ignored?

.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

Fixed it!!!

All the solutions given to me are right. The problem with NetBeans is that you have to close NetBeans, clean the cache folder of NetBeans and finally, open again NetBeans to see the changes previously made them in .gitignore file.

halfer
  • 19,824
  • 17
  • 99
  • 186
José Carlos
  • 2,850
  • 12
  • 59
  • 95
  • Take the ! out from before the line. app.properties isn't even listed. – aynber Mar 16 '17 at 17:37
  • Doesn't work. I want to exclude from ignor /vendor/Demo/*. If I take out "!" I'm not ignoring, don't you? – José Carlos Mar 16 '17 at 17:40
  • 1
    Git ignores everything listed in the .gitignore file. Check the documentation here: https://git-scm.com/docs/gitignore Also make sure the file is named .gitignore, not .ignore – aynber Mar 16 '17 at 17:42
  • 1
    Never mind, I see what you're trying to do now. However, according to the documentation, " It is not possible to re-include a file if a parent directory of that file is excluded. " – aynber Mar 16 '17 at 17:44
  • Thank you, but I don't understand how I can exclude from ignore the file ".gitkeep" and I cannot exclude from ignore everything under vendor/Demo directory :( – José Carlos Mar 16 '17 at 17:44
  • 2
    Possible duplicate of [.gitignore exclude folder but include specific subfolder](http://stackoverflow.com/questions/5533050/gitignore-exclude-folder-but-include-specific-subfolder) – aynber Mar 16 '17 at 17:48
  • As you will be aware, chatty material is discouraged here. In particular, please do not make suicide threats, even in jest - that's not really something to joke about. Keep the material focussed on the technical aspects please. – halfer Sep 21 '17 at 17:00

2 Answers2

2

But I want to exclude from ignore all the files that are under /vendor/Demo/library/File directory,

Fist ignore vendor content, not vendor itself (the folder).
That is because: It is not possible to re-include a file if a parent directory of that file is excluded.

/vendor/*

No need for all the other vendor/xxx rules here.

Then exclude the folders for that ignore rule:

!/vendor/**/

Finally, exclude the files you want:

!/vendor/Demo/library/File/**
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
2

you should turn off "Ignore vendor folder from versioning" here

enter image description here

and "Permanently ignore non-sharable" here

enter image description here

webmak10
  • 479
  • 1
  • 7
  • 18