Git configuration file specifying intentionally untracked files and directories that Git should ignore, preventing build artifacts, dependencies, and secrets from being committed.
.gitignore
.gitignore is a Git configuration file that lists intentionally untracked paths — the files and directories Git should never stage or commit. Placed at the repository root or nested per-directory, it uses glob patterns to keep build artifacts, dependency folders, local environment files, and, critically, secrets out of version history. It is the first line of defense against accidentally publishing something that should never leave a developer’s machine.
- Glob-pattern matching - Patterns like
node_modules/,*.log, and.envexclude whole classes of files at once. - Negation and precedence - A leading
!re-includes a path, and more specific rules override broader ones. - Layered scope - Repository-level, global, and directory-level ignore files compose into the effective rule set.
- Secret hygiene - Excluding
.env, key files, and credential dumps keeps sensitive material out of the commit graph.
In API operations, repositories now carry OpenAPI definitions, GitOps manifests, and infrastructure-as-code that frequently sit next to real credentials during development. A disciplined .gitignore is what stops those secrets from being baked into an auditable, permanent history — a governance concern as much as a convenience. Paired with .gitattributes, it keeps a Git-based source of truth clean enough that automated tooling and agents can trust what the repository actually contains.
Referenced on the API Evangelist blog
Where this standard shows up across sixteen years of my writing at apievangelist.com — how it fits into API design, governance, and the agentic turn.