Ambiguity on .gitignore vs pathspec ... pathspec
- From
- Σταύρος Ντέντος <stdedos@gmail.com>
- Date
- Jan 9, 2023, 17:02 UTC
- Message-ID
- <CAHMHMxWta9Q3O9enn_ntAMdQnE2n_2RPA_Tg0psM+4BEE8dpeA@mail.gmail.com>
Hello there,
I believe I have found a behavior that I cannot explain via the manpages https://git-scm.com/docs/gitignore#_pattern_format and https://git-scm.com/docs/gitglossary#Documentation/gitglossary.txt-aiddefpathspecapathspec:
For the repo:
```
$ git-ls-files$ (master +) tree
.
├── a
│ └── schemas
│ ├── a_schema.json
│ ├── a_schema.yaml
│ ├── fema.json
│ └── fema.yaml
├── b
│ └── schemas
│ ├── a_schema.json
│ ├── a_schema.yaml
│ ├── fema.json
│ └── fema.yaml
└── schemas
├── a_schema.json
├── a_schema.yaml
├── fema.json
└── fema.yaml5 directories, 12 files ```
and all YAML files committed, I get:
``` git-ls-files$ (master +) git status On branch master Changes to be committed: (use "git restore --staged <file>..." to unstage) new file: .gitignore
Untracked files: (use "git add <file>..." to include in what will be committed) a/schemas/a_schema.json a/schemas/fema.json b/schemas/a_schema.json b/schemas/fema.json
git-ls-files$ (master +) cat .gitignore **schemas/*.json git-ls-files$ (master +) git ls-files '**schemas/*.yaml' a/schemas/a_schema.yaml a/schemas/fema.yaml b/schemas/a_schema.yaml b/schemas/fema.yaml schemas/a_schema.yaml schemas/fema.yaml git-ls-files$ (master +) git ls-files '**/schemas/*.yaml' a/schemas/a_schema.yaml a/schemas/fema.yaml b/schemas/a_schema.yaml b/schemas/fema.yaml ```
It seems to me that I have to use different pathspec definition in the `.gitignore` file, and different on the commands (and they are "exactly opposite" :/)
With regards, Ntentos Stavros