I had the following simple .gitignore file.
# Local .terraform directories. Here .terraform is a folder
**/.terraform/*
# .tfstate files
*.tfstate
*.tfstate.*
# .tfvars files
*.tfvars
# .tfplan files
*.tfplan
# .pem files
*.pem
# .hcl files from Terraform v0.14 and newer
*.hcl
# working directory for web app
/globo_web_app/*
**/next-step.txt
Note that this makes git to ignore .terraform.lock.hcl
file as well.
Also note that .terraform.lock.hcl
is not inside of .terraform folder. See the shot below.
But Now I learnt that this .terraform.lock.hcl
file
I tried adding !.terraform.lock.hcl
as shown be in the above screen shot. But it does not seem to work. Any ideas?
CodePudding user response:
Notice you still have this line in your .gitignore
:
*.hcl
which, as you know, ignores all .hcl
files. If you've added the !.terraform.lock.hcl
before that line, it will not work. You need to change it to:
*.hcl
!.terraform.lock.hcl