背景

GitHubは1ファイルのサイズ上限が100MBになっています。その制限に抵触した場合にcommitを戻したりしたので、記録します。

100MBオーバーのファイルをPUSHしたら

テスト用に200MBぐらいのファイルを作って、PUSHしたらファイルサイズが大きいと怒られました。

$ git push
Enumerating objects: 77, done.
Counting objects: 100% (77/77), done.
Delta compression using up to 4 threads
Compressing objects: 100% (68/68), done.
Writing objects: 100% (73/73), 50.93 MiB | 1.77 MiB/s, done.
Total 73 (delta 43), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (43/43), completed with 3 local objects.
remote: error: Trace: 10d8486a3ac1041e91af885e9e05748af4fa9da4753873286f74c0d8098ed37a
remote: error: See https://gh.io/lfs for more information.
remote: error: File 2.txt is 221.12 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File 1.txt is 275.57 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File 1.txt is 275.40 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File 2.txt is 216.00 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
To github.com:yamadatt/xxxxx.git
 ! [remote rejected]   master -> master (pre-receive hook declined)
error: failed to push some refs to 'github.com:yamadatt/xxxxx.git'

対応

以下を実施します。

戻りたい場所まで戻す

git logで戻したいコミットを探します。

戻します。

git reset --soft c93433c

ファイルをコミット

後はファイルをコミットしてPUSHします。

PUSHで怒られたら、-fで強引にPUSHします。