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.

Mornor
  • 3,471
  • 8
  • 31
  • 69
  • Dunno, simple Google Search will not [help](https://medium.com/@mrkdsgn/fixing-the-gh001-large-files-detected-you-may-want-to-try-git-large-file-storage-43336b983272)? – Croolman Jan 09 '19 at 09:30
  • I did not found this answer by googling my problem, and that was the solution to my issue. Thanks! – Mornor Jan 09 '19 at 09:55
  • https://stackoverflow.com/search?q=%5Bgit%5D+remove+large+file+history – phd Jan 09 '19 at 12:27
  • @phd I have not found any answers in SO before. Otherwise I wouldn't have asked a question. – Mornor Jan 09 '19 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 [tag:git] and (b) have those keywords in them. Then you'll find the linked duplicate. – torek Jan 09 '19 at 14:44
  • Ah ok! Thanks for the info :) – Mornor Jan 09 '19 at 15:42

2 Answers2

2

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

Mornor
  • 3,471
  • 8
  • 31
  • 69
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.

Arpit Aggarwal
  • 27,626
  • 16
  • 90
  • 108