dvc and git does not behave the same with "!" and "**"
See original GitHub issueConsider the following project structure
- data
- data1
- file1
- file1.dvc
- data2
- file2
- file2.dvc
- data1
- .gitignore
.gitignore is as follows:
data/**
!data/*/
!*.dvc
git status gives:

while dvc push gives:

I expect to git and dvc behave the same with gitignore.
- dvc: 2.8.3
- python: 3.7
Issue Analytics
- State:
- Created 2 years ago
- Comments:16
Top Results From Across the Web
Dvc exp show: experiment not showing / wrong position
Using dvc exp branch just creates a new git branch that contains the contents of the experiment. It does not move/re-associate the experiment...
Read more >checkout: file replacing behaviour and unnecessary user ...
@dmpetrov dvc checkout is the same as git checkout (which does not behave the way you described). dvc checkout is not the same...
Read more >Is the default DVC behavior to store connection data in git?
1 Answer 1 Β· --local - repository level, ignored by git by default - designated for project-scope, sensitive data Β· project - same...
Read more >Data Version Control With Python and DVC - Real Python
It's not easy to keep track of all the data you use for experiments and the ... While Git is used to store...
Read more >Data and Machine Learning Model Versioning with DVC
However, Git is not the best solution to solve the ... The files with .dvc extension are text files that will act as...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Whether it is was a bug or a bug fix, some commits reverted, and a test case added π
By the way, I think there is a separate issue with dvc.
In our testcase, if we re-include βdata1β directory by
!data/*/, dvc ignores.dvcfiles insidedata1; but if it is done by!data/**/, dvc behaves as expected.In either of cases,
.dvcfiles insidedata1directory are not ignored by git and thecheck-ignoreoutput is as follows:I used another git version, 2.17.1.
Sorry for late reply.
While in
dvc add data/data2/bAnd if we change
!data/*/to!data/**/So I guess there are two problems:
While for the Git:
They give the same result.
addwork properly whilepushandcommitare not)And for the logic of gitignore, the following from the thread is quite clear I think
Git opens and reads the working tree directory. For each file or directory that is actually present here, Git checks it against the ignore rules. Some rules match only directories and others match both directories and files. Some rules say βdo ignoreβ and some say βdo not ignoreβ.
The last applicable rule wins.
If this is a file and the file is ignored, itβs ignored. Unless, that is, itβs in the index already, because then itβs tracked and canβt be ignored.
If this is a directory and the directory is ignored, itβs not even opened and read. Itβs not in the index because directories are never in the index (at least nominally). If it is opened and read, the entire set of rules here apply recursively.