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 must be checked into VC. So it should not be ignored by git.
I am not able to achieve that.
I tried adding !.terraform.lock.hcl
as shown be in the above screen shot. But it does not seem to work. Any ideas?