Answer the question
In order to leave comments, you need to log in
How to ignore all but one folder in Git?
Suppose the project has the following structure:
I only need to track changes in the dev directory.
In .gitignore I write like this:
*
!/dev/
# gitignore
/*.*
/*/*
!/dir1/dir11
!/dir2/dir21
!/dir3/dir31
!/dir4/*
Answer the question
In order to leave comments, you need to log in
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
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question