*.log ignores every file whose name ends in .log, but !debug.log re-includes the top-level file of that exact name, so debug.log will be shown by git status if untracked.
/config/*.yaml ignores YAML files directly inside the config directory; the later negation !/config/production.yaml re-includes production.yaml. Because the config directory itself is not ignored, the override works and config/production.yaml is tracked.
docs/ tells Git to ignore the entire docs directory. When a directory is ignored, Git stops scanning its contents, so a later rule cannot re-include items inside it. Therefore !/docs/README.md has no effect and docs/README.md remains ignored.
scripts/run.sh is not matched by any pattern and will be tracked normally.
Consequently, docs/README.md is the only file that will not appear in git status.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
Why does the '!/docs/README.md' rule not override 'docs/' in the .gitignore file?
Open an interactive chat with Bash
How do negations using '!' work in a .gitignore file?
Open an interactive chat with Bash
How can you ensure files within an ignored directory are tracked in Git?
Open an interactive chat with Bash
CompTIA Linux+ XK0-006 (V8)
Automation, Orchestration, and Scripting
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
IT & Cybersecurity Package Join Premium for Full Access