.gitignore for Terraform

14 ignore rules for Terraform, ready to copy into your repository.

Infrastructure as code tool

The complete .gitignore for Terraform

# Generated by LFGitignore - https://lfgitignore.com
# Created: 2026-08-05 01:32:19 UTC
# Technologies: Terraform

### Terraform ###
.terraform/
# Terraform state file
*.tfstate
# Terraform state backups
*.tfstate.*
crash.log
crash.*.log
# Terraform variables
*.tfvars
# Terraform JSON variables
*.tfvars.json
override.tf
override.tf.json
# Terraform overrides
*_override.tf
.terraform.tfstate.lock.info
# Terraform JSON overrides
*_override.tf.json
# Terraform CLI config
.terraformrc
# Terraform CLI config
terraform.rc

What these Terraform rules actually ignore

Every pattern below, and why it belongs in your .gitignore.

Local .terraform directories

Pattern What it ignores
.terraform/ Local .terraform directories
*.tfstate Terraform state file
*.tfstate.* Terraform state backups

Crash log files

Pattern What it ignores
crash.log Crash log files
crash.*.log Crash log files
*.tfvars Terraform variables
*.tfvars.json Terraform JSON variables
override.tf Ignore override files as they are usually used to override resources locally and so are not checked in
override.tf.json Crash log files
*_override.tf Terraform overrides
*_override.tf.json Terraform JSON overrides

Ignore transient lock info files created by terraform apply

Pattern What it ignores
.terraform.tfstate.lock.info Ignore transient lock info files created by terraform apply

Ignore CLI configuration files

Pattern What it ignores
.terraformrc Terraform CLI config
terraform.rc Terraform CLI config

How to use this .gitignore for Terraform

  1. Copy the Terraform rules above, or download the file directly.
  2. Create a file named .gitignore at the root of your Git repository and paste the rules into it.
  3. If some of those files are already tracked, run git rm -r --cached . then commit again — Git only applies ignore rules to untracked files.
  4. Commit the .gitignore so everyone on the team shares the same rules.

Other DevOps .gitignore templates

See every DevOps template