0

I'm trying to make a .gitignore

I have a directory like :

.
folder
folder/readme.txt
folder/xxx.txt
folder/sub1
folder/sub2

I don't know the name/amount of files or subfolders in folder/

I'd like to make a rule that ignore all subfolders in folder/ but that keep all the files folder/file.smthg so I can only see :

.
folder
folder/readme.txt
folder/xxx.txt
IggY
  • 3,005
  • 4
  • 29
  • 54
  • 1
    Possible duplicate of [Make .gitignore ignore everything except a few files](http://stackoverflow.com/questions/987142/make-gitignore-ignore-everything-except-a-few-files) – hrust Nov 13 '15 at 11:07
  • @Synaps I don't think it is, as I explained in the answer `I don't know the name/amount of files or subfolders in folder/` therefore I cannot make a rule that exclude them from the ignoring pattern, as the answers suggest in the question you linked – IggY Nov 13 '15 at 11:08
  • Possible duplicate : http://stackoverflow.com/a/987162/4088809 – Tahar Bakir Nov 13 '15 at 11:10
  • I recommend not to use the first answer suggested by Synaps, because you may run into this [issue](http://stackoverflow.com/questions/33189437/explain-gitignore-pattern-matching/33190653#33190653), instead, I suggest go with this [pattern](http://stackoverflow.com/a/16318111/1699979) in the same question. – rajuGT Nov 13 '15 at 11:10
  • @TaharBakir : please refer to the comment I done above yours – IggY Nov 13 '15 at 11:10
  • @rajuGT : please refer to my first comment, this question is not a duplicate of the one linked by Synaps or rajuGT – IggY Nov 13 '15 at 11:12

2 Answers2

1

Exclude folders using */

So your gitignore could be something like this

folder/*/
Holloway
  • 6,412
  • 1
  • 26
  • 33
0

Maybe you can use Wildcards?

    folder/*/*

You can also use the double wildcard (**) to match all level of subdirectories :

    **/folder/test/
Vlu
  • 57
  • 4