I am trying to use Terraform and have a local Gitrepo connected to my remote Github account. When i run Terraform plan it creates a .terraform folder which has the providers installed and the size of the file is more than 100MB. So when i try to do Git Push origin master, the push is rejected by Github because of this .terraform folder size which is more than 100 MB So i created a .gitignore file in my local laptop from the template of Terraform .gitignore. So now in the .gitignore file i have my .terraform folder added. I have already did "git add .gitignore" and then tried to push my repo again to remote Github account it was still failing. So then i deleted the Github repository and created a new repository in Github and while creating i got the option to add a .gitignore file and i chose the Terraform .gitignore from the drop down . After i created the .gitignore file from the Github side, i was then able to push my local repo to Github this time by typing " Git push origin master"
So i would like to know why if you create a .gitignore file locally in your local laptop and add the path of the big folders and files that you want to exclude from the push and then try to do Git Push fails and it doesn't work? Why it works if you create from the Github side, any idea plz.. ?