B
B
Boris Dergachev2014-11-22 11:54:22
git
Boris Dergachev, 2014-11-22 11:54:22

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

In this example, the rule should only ignore ".a" and ".b".

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Boris Dergachev, 2014-11-22
@froex

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 question

Ask a Question

731 491 924 answers to any question