Umi and Satomi

シーズー犬うみと飼い主Satomiが楽しく生活してみます

Git trouble: commit file size become too bigger

http://4.bp.blogspot.com/-DgbWOL_tk-U/UOtkmMlHzeI/AAAAAAAAKjs/dcLmuHzZ1S4/s640/3632.jpg

Generating Rails project, and come to phase to commit it. The file size is even more than my expectation.

$ git push origin master
Counting objects: 26593, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (24906/24906), done.
Writing objects: 100% (26593/26593), 157.41 MiB | 160.00 KiB/s, done.
Total 26593 (delta 4255), reused 0 (delta 0)
remote: error: GH001: Large files detected.
remote: error: Trace: 
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File vendor/bundle/ruby/2.2.0/gems/libv8-3.16.14.7-x86_64-darwin-14/vendor/v8/out/x64.release/libv8_base.a is 150.14 MB; this exceeds GitHub's file size limit of 100 MB
To git@github.com:hoge/hgoe.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@github.com:hoge/hoge.git'

Handling

remove .git. and git init again

I found too much files under .git/objects/ I thought this is reason. But I didn't understand git system well, so I adopted simpler solution.

$ rm -rf .git && git init

Result

$ git push bb master
Counting objects: 135, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (118/118), done.
Writing objects: 100% (135/135), 162.30 KiB | 0 bytes/s, done.
Total 135 (delta 10), reused 0 (delta 0)
To 
 * [new branch]      master -> master

omg..... what is this difference......? unbelievable....

# before
26593, 157.41 MiB

# after
135, 162.30 KiB

Cause

committed installed gem files

I wrote much gem on Gemfile. and command $ bundle install --path vendor/bundle so installed gem files are under vendor/bundle

basically using .gitignore, remove vendor/bundle from git target. But unfortunately cache worked badly and didn't reflect change of .gitignore

Very easy to remove cache.

$ git rm -r --cached .