Git ignore everything except some subdirectories

I need to manage only the "debian" subdirectories in my tree:

pkg/.git
pkg/.gitignore
pkg/package1/package1-2.2.1/debian
pkg/package2/package2-1.0/debian

I tried this type of .gitignore, but it will not work:

*
!.gitignore
!*/*/debian

When i started

git add package1 / package1-2.2.1 / debian

git Answer: The following paths are ignored by one of your .gitignore files: package1

This is quite logical. Any help would be appreciated!

+5
source share
2 answers

You can add it with:

git add -f package1/package1-2.2.1/debian

, .gitignore, , , - , . , , .git/info/exclude.

+2

gitignore !:

An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence patterns sources.

, , !. !.gitignore , git add.

-1

All Articles