Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

.gitignore

Direct answer

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

When to use this

Use it when configuring, checking or troubleshooting .gitignore in Git.

First 30 seconds

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.

Operational verification

file → ignore rules → not tracked

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Git version-control automation
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformGit version-control automation · .gitignore owns Git ignore-pattern behavior. Secret management and history-remediation procedures belong to security/credential and repository-governance controls.
Scope / prerequisiteUse it when configuring, checking or troubleshooting .gitignore in Git.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

4 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

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
  • .gitignore added 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 references

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.

observation · 1
Key points
  • 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.
Key checks
  • cat .gitignore — patterns
  • git check-ignore -v <file> — why ignored
  • git 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.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docGit version-control automation current

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%
Terminology layer

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.

Aliases that resolve here
gitignore.gitignoreignore patternsgit ignored files
Embedded reference data

Quick lookup tables

.gitignore Git boundary map

Fast local-state, history/ref, remote and downstream proof boundaries for .gitignore.

BoundaryHealthy evidenceSuspicious evidence
Local stateRepository, HEAD, worktree/index and commit IDs are explicitWrong repo/ref, hidden staged/untracked state or mutable-name ambiguity
History / refsAncestry and branch/tag movement match intentUnexpected rewrite, stale tracking ref or unclear merge base
Remote syncURL/refspec, auth and remote read-back match expected commitsLocal assumptions, rejection, stale fetch or unsafe force update
Downstream proofBuild/reconciliation/target is verified independentlyPush/tag/merge success treated as deployment success
Depth when you need it

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.

Confirmation

Confirm action

Continue?