D
D
Dmitry2018-08-08 16:23:39
git
Dmitry, 2018-08-08 16:23:39

How to ignore all but one folder in Git?

Suppose the project has the following structure:
0e1dea2b3c.png
I only need to track changes in the dev directory.
In .gitignore I write like this:

*
!/dev/

But it doesn't work. dev is ignored. How can the problem be solved?
UPD.
It turned out something like this:
# gitignore
/*.*
/*/*
!/dir1/dir11
!/dir2/dir21
!/dir3/dir31
!/dir4/*

Answer the question

In order to leave comments, you need to log in

3 answer(s)
L
Lynn "Coffee Man", 2018-08-08
@Thelema

You * match any file in any folder.
As a result , the dev folder is not ignored, but all files in it are ignored because they match the * rule .
You can do this:

# игнорируем всё в корне
/*
# кроме папки /dev
!/dev

D
Denis Melnikov, 2018-08-08
@Mi11er

can just do git init in dev folder?

V
Vadim Shatalov, 2018-08-08
@netpastor

Try

*
/!dev/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question