0

I have some tree structure:

/a  
/a/a  
/a/b
/b/
..  
/a/z  
/b  
.. (thousands of folders)  
/z  

How can I control just /a/a and /b folders?
What exclude file should be?
The way we use now is:

/a/*    
/c/
..  (thousands of folders)  
/z/  
!/a/a  

But it is very not nice looking and hard for maintenance...

Olga Pshenichnikova
  • 1,509
  • 4
  • 22
  • 47

2 Answers2

0

According to this answer standard globbing rules are used in the .gitignore syntax so you can't use standard regular expressions to solve this problem.

That said, you can shorten your gitignore a bit. This pattern will exclude all folders other than a and b:

[cdefghijklmnopqrstuvwxyz]
Community
  • 1
  • 1
Jonathan.Brink
  • 23,757
  • 20
  • 73
  • 115
  • Sorry, but I need also include directory /b ) – Olga Pshenichnikova Mar 07 '16 at 18:54
  • @Olga It can make your `.gitignore` file a little more managable by not having to specify every folder on it's own line – Jonathan.Brink Mar 07 '16 at 19:00
  • mmm... thanx... it is very sad that git can not support such case... I think in our case it will harder to handle folders on same line... because we have much .gitignore files describes similar environments, and we need sometime remove or add folders and copy lines from each to other... But thank you for help ) – Olga Pshenichnikova Mar 07 '16 at 19:11
0

OK, I solved it!

/*
!/a/
/a/*
!/a/a/
!/b/  

It was thousand of lines, now it just five )))

Olga Pshenichnikova
  • 1,509
  • 4
  • 22
  • 47