Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git ignore everything but some subdirectories

Tags:

git

gitignore

I need to control only "debian" subdirectories on my tree :

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

I tried this kind of .gitignore but it won't work :

*
!.gitignore
!*/*/debian

When I run

git add package1/package1-2.2.1/debian

git's answer is : The following paths are ignored by one of your .gitignore files: package1

Which is quite logical. Any help would be appreciated !

like image 695
Falken Avatar asked Nov 14 '22 23:11

Falken


1 Answers

You can still add it with:

git add -f package1/package1-2.2.1/debian

You probably don't want to ignore your .gitignore file, by the way, since you'll want to know when you have to commit any changes you've made to it. If you don't want the ignore rules to be committed in the repository, you should use .git/info/exclude instead.

like image 55
Mark Longair Avatar answered Dec 09 '22 14:12

Mark Longair