public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* Re: .gitignore issue
@ 2026-01-21 18:51 Pushkar Singh
  2026-01-21 21:03 ` Jeff King
  0 siblings, 1 reply; 4+ messages in thread
From: Pushkar Singh @ 2026-01-21 18:51 UTC (permalink / raw)
  To: alf.clement@gmail.com; +Cc: git@vger.kernel.org

Hi Alf,

This is expected behavior.
When a directory matches an ignore rule, Git stops descending into it entirely. The pattern

        backup_STOCKS*/

matches directories starting with backup_STOCKS, and once Git prunes traversal at that level, similarly prefixed paths can disappear from git status, which is why backups/ no longer shows up.

This isn’t a bug, but a result of how ignore patterns and directory pruning work.

If you want to ignore only those directories and nothing else, anchoring the pattern helps:

        /backup_STOCKS_*/

You can also verify which rule is responsible with:

        git check-ignore -v backups/

Hope that clears it up.

Best,
Pushkar

^ permalink raw reply	[flat|nested] 4+ messages in thread
* .gitignore issue
@ 2026-01-21 18:32 Alf Clement
  0 siblings, 0 replies; 4+ messages in thread
From: Alf Clement @ 2026-01-21 18:32 UTC (permalink / raw)
  To: git

Hello,

I found an unexplainable behavior - see below.

best regards,
Alf

Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)
Adding an new line to .gitignore to filter directories.

What did you expect to happen? (Expected behavior)
I expected to see no backup_STOCKS* directory on git status.

What happened instead? (Actual behavior)
It also surpressed the backup/ directory.

What's different between what you expected and what actually happened?
When I surpress backup_STOCKS* or backup_STOCKS*/ I expect a backup/
directory still to be visible.

Anything else you want to add:
Here are the actions:

$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   .gitignore

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        asset_history_2025_20260114.csv
        backup_STOCKS_20260107_060326/
        backup_STOCKS_20260107_184151/
        backup_STOCKS_20260110_173702/
        backup_STOCKS_20260114_172546/
        backup_STOCKS_20260116_201409/
        backup_STOCKS_20260116_210037/
        backup_STOCKS_20260117_184437/
        backup_STOCKS_20260119_202817/
        backups/
        index.after.txt
        index.before.txt

no changes added to commit (use "git add" and/or "git commit -a")
$ echo 'backup_STOCKS*/' >>.gitignore
$ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   .gitignore

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        asset_history_2025_20260114.csv
        index.after.txt
        index.before.txt
$ cat .gitignore
png/
__pycache__
mongodb.yaml
*.log
*.pdf
OLD
.vscode
ca.pem
py.pem
states/
.skylos
backup_STOCKS*/

[System Info]
git version:
git version 2.43.0
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC
Thu Jun  5 18:30:46 UTC 2025 x86_64
compiler info: gnuc: 13.3
libc info: glibc: 2.39
$SHELL (typically, interactive shell): /bin/bash


[Enabled Hooks]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-01-21 21:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-21 18:51 .gitignore issue Pushkar Singh
2026-01-21 21:03 ` Jeff King
2026-01-21 21:09   ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2026-01-21 18:32 Alf Clement

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox