Git push issue

Sorry, noob here. I’m using gitlab.com free tier to learn and improve my skills with GitLab and DevOps stuff.
I’m using terraform with AWS.
Everything worked fine before I set the state file to work from gitlab.
I followed a guide and in one section I had to run these rows to my instance:

export PROJECT_ID=“”
export TF_USERNAME=“”
export TF_PASSWORD=“”
export TF_ADDRESS=“https://gitlab.com/api/v4/projects/${PROJECT_ID}/terraform/state/tf_state

terraform init
-backend-config=address=${TF_ADDRESS}
-backend-config=lock_address=${TF_ADDRESS}/lock
-backend-config=unlock_address=${TF_ADDRESS}/lock
-backend-config=username=${TF_USERNAME}
-backend-config=password=${TF_PASSWORD}
-backend-config=lock_method=POST
-backend-config=unlock_method=DELETE
-backend-config=retry_wait_min=5

After that the ,git push" doesn’t work anymore as it is downloading the aws provider’s .exe which is 438MB. I’ve already deleted the file, tried to push, but same issue.
What I tried:
git gc
git fetch --all
created .gitignore file to exclude .exe

PS C:\VSCode\AWS_practice> git push
Enumerating objects: 28, done.
Counting objects: 100% (27/27), done.
Delta compression using up to 12 threads
Compressing objects: 100% (14/14), done.
Writing objects: 100% (24/24), 96.97 MiB | 13.49 MiB/s, done.
Total 24 (delta 7), reused 18 (delta 3), pack-reused 0 (from 0)
remote: GitLab: You are attempting to check in one or more blobs which exceed the 100.0MiB limit:
remote:
remote: - 6c48dcaf051d222a882ff863b84c5fa8ae8f2460 (438 MiB)
remote: To resolve this error, you must either reduce the size of the above blobs, or utilize LFS.
remote: You may use “git ls-tree -r HEAD | grep $BLOB_ID” to see the file path.
remote: Please refer to Free push limit | GitLab and
remote: Account and limit settings | GitLab
remote: for further information.
To https://gitlab.com/xyz/AWS_practice.git
! [remote rejected] main → main (pre-receive hook declined)
error: failed to push some refs to ‘https://gitlab.com/xyz/AWS_practice.git

As you can see the file is not there anymore as I deleted, but the push no longer works.
PS C:\VSCode\AWS_practice> git ls-tree -r HEAD
100644 blob adb36c821965862397d65fa68e26cd2433c97140 .gitignore
100644 blob 46a9e51376d6fc75815c4881895161b8c4c67f78 .gitlab-ci.yml
100644 blob c55f45d722f81c218e395c92e4087b030e1f8111 .terraform.lock.hcl
100644 blob d3ab2b9ef5d5c57d1ec6fb04db54c658b39ecafb README.md
100644 blob d40b45a9cda32e8a442ca994b59c9f62f9c56039 ec2.tf
100644 blob a80926ca56b4f428bd8b892941bb532524ddc311 main.tf
100644 blob 8e5d32cb1165946de21dfd746efbdc522fda5b53 s3.tf
100644 blob 34a07ca8a5494ad3956ba8e1db6d2347818f44db terraform.tfvars
100644 blob 30e1473436f65bd0c898268e20c42b85a8140807 variables.tf

Do you have any idea what should I do or what can be the problem?

The file is in your Git history, deleting it afterwards has no effect on its existence. To resolve this, you’ll need to reset the commits and create a state where no binary blog is checked into Git.

This command will reset one commit, but keep all changes locally.

git reset --soft HEAD^

You can repeat this until only the first commit is in the repository.

Then start with adding the .gitignore file

git add .gitignore
git commit -vm "Add .gitignore" .gitignore 

git add -A
git commit -avm "Add data"

git push

If the first commit actually included the large binary blob, a different approach needs more destructive actions with deleting the local git repository storage, re-creating it, and then connecting it again to the remote repository.

rm -rf .git/

git init 

# Make sure that the .gitignore file contains *.exe

git add -A
git commit -avm "Initial commit"

git remote add origin https://gitlab.com/xyz/AWS_practice.git

git push

You can also use the destructive approach if you feel that the commit-reset strategy is too complicated. I use that workflow sometimes when I do similar things, like checking in node_modules/ by accident in early stage projects.

Thank you so much! It is working again!

1 Like