2

I am trying to push my .git to Github.

git push origin master
[...]
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: fc1cc7aed3765ca1e847dee4b7fc831f
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File .terraform/plugins/darwin_amd64/terraform-provider-aws_v1.41.0_x4 is 107.37 MB; this exceeds GitHub's file size limit of 100.00 MB
To [example].git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@[example.git].git'

Which tells me that

.terraform/plugins/darwin_amd64/terraform-provider-aws_v1.41.0_x4 

Is too big.

Fair enough:

rm -rf .terraform/
git rm -rf .terraform/
git rm -rf --cached .terraform/

Which gives

git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    deleted:    .terraform/plugins/darwin_amd64/lock.json
    deleted:    .terraform/plugins/darwin_amd64/terraform-provider-aws_v1.41.0_x4

So, seems to be okay.

However, when pushing one more time (after commit), I got the exact same issue I have at the very beginning.

Except this time I have no more .terraform, neither in my .git nor in my local folder.

What is causing the issue, and how should I solve it?
I suspect there is some git history to be re-written, but not sure about that. Appreciate any help!

EDIT No, the other SO answers did not help with my case.
Please see the answer I gave below.

6
  • Dunno, simple Google Search will not help? Commented Jan 9, 2019 at 9:30
  • I did not found this answer by googling my problem, and that was the solution to my issue. Thanks! Commented Jan 9, 2019 at 9:55
  • stackoverflow.com/search?q=%5Bgit%5D+remove+large+file+history Commented Jan 9, 2019 at 12:27
  • @phd I have not found any answers in SO before. Otherwise I wouldn't have asked a question. Commented Jan 9, 2019 at 13:11
  • Mornor: @phd is showing you how to write a good query: in the search box, type [git] remove large file history, and SO will bring up probably-relevant questions and answers that are (a) tagged git and (b) have those keywords in them. Then you'll find the linked duplicate. Commented Jan 9, 2019 at 14:44

2 Answers 2

3

As @Croolman pointed out, the following command fixed my issue:
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch .terraform/'

Sign up to request clarification or add additional context in comments.

Comments

1

It's because commit you are trying to push still knows about .terraform/ to avoid it discard the last commit executing a command:

git reset --hard HEAD~1

Then create a new commit after deleting .terraform/ from the git history and push it to Github.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.