Answer the question
In order to leave comments, you need to log in
How to ignore directories but not files (.gitignore) in Git?
There are files and directories in the repository that start with a dot. How can I specify rules in .gitignore to ignore all directories that start with a dot, but not ignore files that start with a dot? It is not known in advance which directories and files will be in the project. There can be a lot of them, so manually specifying each ignored directory is extremely inconvenient.
Example files in the repository:
.a - dir
.b - dir
.c - file
.d - file
Answer the question
In order to leave comments, you need to log in
Sorry for answering myself in a short time after posting the question, but already solved the problem.
I wrote the rule like this: .*/*
This works, because Git does not track directories, so we ignore everything inside directories that start with a dot, and these directories themselves do not need to be specified.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question