コハクウェブデザイン

【解決】Gitで「Large files detected. You may want」のエラーが消えない時

Gitで大きなファイル(100MB以上)のファイルをpushしようとするとこんな風に怒られます。
そしてgitignoreとかを更新して再度pushしようとするとまたエラーがでてpushできないことがあります。

remote: Resolving deltas: 100% (26/26), completed with 11 local objects.
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: abcdefg
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File filename.csv is 865.08 MB; this exceeds GitHub's file size limit of 100.00 MB

そんな時は以下の様にやりましょう。
「filename.csv」のところにひっかかっているファイル名を記入します。

 git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch filename.csv'

ファイルではなくフォルダのときはこうです。
rmの後に「-r」をつけます。

git filter-branch -f –index-filter ‘git rm -r –cached –ignore-unmatch foldername’