my git repo directory like this:
--ignore_dir/
----dir2/
------ignorea3.txt
----aaa.txt
----ignorea2.txt
--ignorea1.txt
--ignore1.txt
--.gitignore
.gitignore
file like this:
/*
!/**/ignorea*.txt
with git status
, it output:
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
ignorea1.txt
nothing added to commit but untracked files present (use "git add" to track)
My question is why it not tracking files: ignore_dir/dir2/ignorea3.txt
and ignore_dir/ignorea2.txt
Thanks!
UPDATE
Thanks @RomainValeri and @torek,
I got a complex way to achieve this, by edit gitignore file:
/*
!/ignore_dir/
/ignore_dir/*
!/ignore_dir/dir2/
/ignore_dir/dir2/*
!/ignore_dir/dir2/ignorea*.txt
!/ignore_dir/ignorea*.txt
It give a explicit tracking every parent level directory of the ignorea*.txt
.
Besides, this will not work:
/*
!**/ignorea*.txt
Hope someone could give a elegant way!