.gitignore for OpenTofu
18 ignore rules for OpenTofu, ready to copy into your repository.
Open-source Terraform fork
The complete .gitignore for OpenTofu
# Generated by LFGitignore - https://lfgitignore.com
# Created: 2026-04-25 17:21:48 UTC
# Technologies: OpenTofu
### OpenTofu ###
# Terraform providers/modules
**/.terraform/*
# Terraform state file
*.tfstate
# Terraform state backups
*.tfstate.*
crash.log
crash.*.log
# Terraform variables
*.tfvars
# Terraform JSON variables
*.tfvars.json
override.tf
override.tofu
override.tf.json
override.tofu.json
# Terraform overrides
*_override.tf
*_override.tofu
# Terraform JSON overrides
*_override.tf.json
*_override.tofu.json
.terraform.tfstate.lock.info
# Terraform CLI config
.terraformrc
# Terraform CLI config
terraform.rc
What these OpenTofu rules actually ignore
Every pattern below, and why it belongs in your .gitignore.
Local .terraform directories
| Pattern | What it ignores |
|---|---|
**/.terraform/* |
Terraform providers/modules |
*.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.tofu |
Crash log files |
override.tf.json |
Crash log files |
override.tofu.json |
Crash log files |
*_override.tf |
Terraform overrides |
*_override.tofu |
Crash log files |
*_override.tf.json |
Terraform JSON overrides |
*_override.tofu.json |
Crash log files |
Ignore transient lock info files created by tofu apply
| Pattern | What it ignores |
|---|---|
.terraform.tfstate.lock.info |
Ignore transient lock info files created by tofu apply |
Ignore CLI configuration files
| Pattern | What it ignores |
|---|---|
.terraformrc |
Terraform CLI config |
terraform.rc |
Terraform CLI config |
How to use this .gitignore for OpenTofu
- Copy the OpenTofu rules above, or download the file directly.
- Create a file named .gitignore at the root of your Git repository and paste the rules into it.
- If some of those files are already tracked, run git rm -r --cached . then commit again — Git only applies ignore rules to untracked files.
- Commit the .gitignore so everyone on the team shares the same rules.