Use it when configuring, checking or troubleshooting .gitignore in Git.
.gitignore
.gitignore lists file patterns Git should not offer to track, such as build output and local settings. It does not affect files already committed — remove those with git rm --cached — and it is not a way to protect secrets.
1. .gitignore excludes generated files, secrets, venvs, state files (*.tfstate, .terraform/).
2. Already tracked files need git rm --cached.
3. Global ignore for editor files.
4. Never rely on it alone for secrets — use scanning.
5. Review regularly.
file → ignore rules → not tracked
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Operational evidence path Verify boundary
path → tracked/index state → applicable ignore sources → pattern precedence/match → status visibility → repository history/security follow-up
Healthy evidence: effective rule source is known, intended untracked files are ignored, tracked files are handled explicitly and secrets are governed outside ignore rules.
Step 2 Failure modes and next checks Narrow the fault
Suspicious evidence: assuming ignore untracks files, broad accidental patterns, negation surprises, global excludes hidden from teammates or treating .gitignore as secret control.
Step 3 Common mistakes Narrow the fault
.gitignoreadded after secrets were committed.
Step 4 Where it fails Narrow the fault
Where .gitignore usually goes wrong: immutable commit/object identity, refs/remotes, history mutation and consumer checkout/build binding.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- Ignored ≠ untracked automatically; files already in the index remain tracked despite matching a .gitignore rule.
- .gitignore ≠ secret protection; ignored files can still be read, copied, logged or force-added.
- Pattern present ≠ pattern matches intended path; anchoring, directory context and negation affect results.
- File absent from status ≠ file absent from repository history; secrets may remain in prior commits.
cat .gitignore— patternsgit check-ignore -v <file>— why ignoredgit status --ignored— ignored files
ReferenceWhat it is1 section · depth on demand
Core model
Evaluate ignore rules by scope, precedence and path matching, then separately inspect tracked state. Repository-local, nested and exclude/global rules can combine, so effective behavior must be observed for the specific path.
ReferenceImportant terms & boundaries2 sections · depth on demand
What this shows and what it does not
An ignore match shows Git will normally suppress an untracked path from discovery; it does not untrack existing content, erase history or secure sensitive data.
In depth
.gitignore lists file patterns Git should not track: build output, virtual environments, local settings, logs. It keeps repositories clean but does not remove files already committed.
.venv/
__pycache__/
*.retry
.terraform/
*.tfstate
*.tfstate.backup
.env
git check-ignore -v .env
git rm --cached secrets.yml # stop tracking an already committed file
Ignoring a file does not protect a secret that was already committed — rotate the secret and remove it from history if needed.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Git > .gitignore. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://git-scm.com/docs · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Quick lookup tables
.gitignore Git boundary map
Fast local-state, history/ref, remote and downstream proof boundaries for .gitignore.
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Local state | Repository, HEAD, worktree/index and commit IDs are explicit | Wrong repo/ref, hidden staged/untracked state or mutable-name ambiguity |
| History / refs | Ancestry and branch/tag movement match intent | Unexpected rewrite, stale tracking ref or unclear merge base |
| Remote sync | URL/refspec, auth and remote read-back match expected commits | Local assumptions, rejection, stale fetch or unsafe force update |
| Downstream proof | Build/reconciliation/target is verified independently | Push/tag/merge success treated as deployment success |
Deep reference
Healthy vs suspicious evidence
Output interpretation
For .gitignore, rely on structured fields and stable IDs (immutable commit/object identity, refs/remotes, history mutation and consumer checkout/build binding) rather than text formatted for display.