If there is a separator at the beginning or middle (or both) of the pattern, then the pattern is relative to the directory level of the particular .gitignore file itself. Otherwise the pattern may also match at any level below the .gitignore level.
They also give two examples:
For example, a pattern doc/frotz/ matches doc/frotz directory, but not a/doc/frotz directory; however frotz/ matches frotz and a/frotz that is a directory (all paths are relative from the .gitignore file).
A leading ** followed by a slash means match in all directories. For example, **/foo matches file or directory "foo" anywhere, the same as pattern "foo".
Currently I believe tree --gitignore doesn't follow this correctly. #1 is a similar issue. If we consider the following directory structure:
Hi,
This is a small fix for the
--gitignore
option.According to the gitignore manual,
They also give two examples:
Currently I believe
tree --gitignore
doesn't follow this correctly. #1 is a similar issue. If we consider the following directory structure:If
.gitignore
containsthen
git add .
followed bygit status
yieldsdir_b/b.txt
as the only added file, i.e. directoriesdir_a
anddir_b/dir_a
are both ignored. Buti.e.
dir_a
is ignored but notdir_b/dir_a
.On the other hand if
.gitignore
containsthen
dir_b/b.txt
anddir_b/dir_a/ab.txt
both files are added, i.e. only the outer directorydir_a
is ignored. Buti.e. the outer directory
dir_a
is not ignored.With this fix we get the expected result in both cases: in the first case
and in the second
Please let me know your comments! Thanks!