.gitignore
A text file of patterns naming untracked files Git should not report or add, such as build output and logs.
In more detail
Each line is a glob pattern: *.log matches by extension, a trailing slash as in build/ matches only directories, a leading slash anchors the pattern to the directory of the .gitignore file, ** matches any number of folders, and ! re-includes a path an earlier rule excluded. A .gitignore in a subdirectory applies from there down and beats the ones above it, and within one file the last matching pattern wins. It never affects files Git already tracks, and it is committed so the whole team ignores the same things.
Examples
*.logbuild/!docs/keep/scratch.md.venv/
__pycache__/
dist/.terraform/
*.tfstate
*.tfstate.*In Terraform: For Terraform it should list the .terraform directory, state files and any variable files holding secrets. The dependency lock file must not be ignored.Related terms
- glob pattern — A pattern that matches names using * for any run of characters, a question mark for one character and [abc] for one of a set.
- tracked file — A file Git already knows about because it is in the last commit or the staging area; any other file is untracked.
- git check-ignore — The command that tells you whether a path is ignored and, with -v, which file, line and pattern ignored it.
- .git/info/exclude — A private ignore file inside .git that works like .gitignore but is never committed, for clutter only you create.
- core.excludesFile — The setting naming a personal ignore file that applies to every repository on your machine.
- git rm — The command that removes a file from the staging area, and from disk unless you add --cached, so the next commit stops tracking it.
- Git — A free, open-source distributed version control system that records the history of a project as a chain of snapshots.
- repository — A project folder whose full history is tracked by version control; in Git, your files plus the hidden .git directory that stores every commit.
- virtual environment — A self-contained folder with its own Python and its own installed packages, so each project's packages stay separate.
- pre-commit hook — A Git hook that runs before a commit is created and can refuse the commit, for example when it contains something shaped like a secret.
- commit history — The full chain of commits in a repository, which keeps every past version of every file, including deleted secrets.
- .terraform directory — The hidden folder terraform init creates beside your configuration, holding downloaded providers, fetched modules and backend settings.
- Terraform state — Terraform's record, usually a JSON file called terraform.tfstate, mapping each resource in the configuration to the real object it created.
Taught in
- Ignoring Files, And The Tracked File Trap — Advanced Git Internals & Distributed Workflows
- Pinned For Stability: Images, Registries And Code — Kubernetes and Cloud Native Security Associate (KCSA) Exam Prep
- Virtual Environments — Hands-on Python: Complete Video Course & Book
- Shipping: scripts, entry points and git — Hands-on Python: Complete Video Course & Book
- Why Secrets Leak — Application Security & Threat Modeling for Engineers
- Initialising The Working Directory — Infrastructure as Code with Terraform
- The Release Tag That Never Left The Laptop: Git Branches, Remotes, Tags And History — CompTIA Linux+ (XK0-006) Exam Prep
- Ansible Vault: Secrets Encrypted, Runs Without A Prompt — RHCE in Ansible (EX294): Automate Red Hat Systems