git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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.yaml

5 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

Message 1 of 1 in “Ambiguity on .gitignore vs pathspec ... pathspec”
  1. Σταύρος ΝτέντοςJan 9, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.