Githubに100MB以上のファイルをpushするとエラーになる

背景

間違えてバックアップしたzipファイルをpushしてしまい容量が100MB超えてた為、エラーになった。 pushしたディレクトリ内に、100MBを超えるファイルがあるからエラーがでる

Githubでは、100MBを超えるファイルはアップロードできない
warningは、50MBを超えているので、今後100MBを超える可能性があるという意味

エラー内容

this exceeds GitHub's file size limit of 100.00 MB

解決方法

1.gitフォルダーを削除

.gitは隠しフォルダなので「command」+「shift」+「.」で表示させる。

2 原因の100MB以上のファイルを削除。
3git init.gitを新規作成。

$ git init
Initialized empty Git repository in /Users/owner/git/menta/springboot_docker/springboot-dev-docker-template-master/.git/

4git remote add origin リポジトリURLを打ち、originという名前でgithubのブランチを追加。

$ git remote add origin https://github.com/meo2718/crud_app_java.git
$ git remote -v
origin  https://github.com/meo2718/crud_app_java.git (fetch)
origin  https://github.com/meo2718/crud_app_java.git (push)

5 ユーザー情報の紐づけ
GitHubのユーザー名とメールアドレスを登録する

$ git config --global user.name ユーザー名
$ git config --global user.email メールアドレス

$ git config --list                    
credential.helper=osxkeychain
user.name=ユーザー名
user.email=メールアドレス
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true

6git add -Aでステージング、git commitでコミットする。

$ git add -A
$ git commit -m 'crud'
$ git branch -M main

7 githubにpushする

$ git push -u origin main
Enumerating objects: 2756, done.
Counting objects: 100% (2756/2756), done.
Delta compression using up to 8 threads
Compressing objects: 100% (1885/1885), done.
Writing objects: 100% (2756/2756), 78.97 MiB | 10.77 MiB/s, done.
Total 2756 (delta 804), reused 0 (delta 0)
remote: Resolving deltas: 100% (804/804), done.
remote: warning: See http://git.io/iEPt8g for more information.
remote: warning: File volumes/db/data/ibdata1 is 76.00 MB; this is larger than GitHub's recommended maximum file size of 50.00 MB
remote: warning: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To https://github.com/meo2718/crud_app_java.git
 * [new branch]      main -> main
Branch 'main' set up to track remote branch 'main' from 'origin'.