Skip to content

gitignore !demos/** un-ignores demos/__pycache__ (bytecode gets tracked) #6

Description

@cognis-digital

Problem

.gitignore ignores __pycache__/ globally, but a later line re-includes everything under demos/:

__pycache__/
...
!demos/**

The !demos/** negation overrides the earlier __pycache__/ rule for that subtree, so running any demo (python demos/run_all.py) creates demos/__pycache__/*.pyc files that git status then reports as untracked/addable. A git add -A will happily commit compiled bytecode.

Repro

PYTHONUTF8=1 python demos/run_all.py
git status --short          # shows demos/__pycache__/*.pyc as ??
git add -A && git status    # bytecode is now staged

Suggested fix

Re-assert the ignore for bytecode after the negation, e.g.:

!demos/**
demos/**/__pycache__/

or scope the negation to source files only (!demos/**/*.py, !demos/**/*.json, !demos/**/*.md).

The .pyc files should never be part of the source tree; they are host/interpreter-version specific (cpython-314 here).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions