Gitignore not working with terraform #23052
-
I am new to github and I’ve tried a few things to successfully push my code to my github account but it won’t work. I’m using Visual studio code and want to push some basic Terraform files to my repo. When I go to push the project, it complains about the large file in the .terraform file. But the terraform directory is clearly excluded in the .gitignore file. I’ve done the following:
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
That looks like that .exe file was already committed to your repository before you added the .gitignore file. A .gitignore file can’t change the repository history, you’ll have to remove the file from history yourself. The procedure is essentially the same as for Removing sensitive data from a repository - GitHub Docs. For editing repository history (and related pitfalls) in general, see: Git - Rewriting History |
Beta Was this translation helpful? Give feedback.
-
yes that’s definitely the issue thanks! But I really wasn’t expecting the fix to be such a headache. Thanks for the links, the first one talks about using git filter-repo, but it requires python to be installed. There must be an easier way to untrack all the initial files? I’ve also tried following this, but it hasn’t worked, that pesky exe is being tracked by git: Untrack files already added to git repository based on .gitignore - CodeBlocQ |
Beta Was this translation helpful? Give feedback.
-
mkx85:
Unfortunately not, unless you want to start over from scratch. Git history is usually meant to be immutable, modifying it is the exception, not the rule.
mkx85:
That guide just adds a commit that removes the files, without cleaning up history. That way the files aren’t being tracked for the future, but are still part of the history. And when you push, all history is pushed. So that guide doesn’t help you here. |
Beta Was this translation helpful? Give feedback.
-
Solution is on this page. Works 100%
Unable to ignore .terraform before pushing to GitHub
I have an error that prevents me from pushing my changes to my GitHub repo:
I understand the issue is the file is too large to push to github. I've tried adding the whole .terraform folder to my .gitignore file using these guides: from GitHub and from Hashicorp. My I've also tried these from several answers on SOF:
I've also tried this. However:
|
Beta Was this translation helpful? Give feedback.
Solution is on this page. Works 100%
Unable to ignore .terraform before pushing to GitHub