Niklas Rosencrantz
Niklas Rosencrantz

Reputation: 26671

Can't git push because file size too large

I did several commits locally without realizing that github doesn't allow > 100 MB files so I have 4 or 5 commits that I was trying to push and now I can't do anything. What am I supposed to do?

$ git push
Counting objects: 114, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (96/96), done.
Writing objects: 100% (114/114), 48.24 MiB | 467.00 KiB/s, done.
Total 114 (delta 54), reused 0 (delta 0)
remote: Resolving deltas: 100% (54/54), completed with 10 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: bc3c170ddc8fcb18b4fd112e6036e0f7
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File app/release/app-release.apk is 139.72 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File app/release/app-release.apk is 135.97 MB; this exceeds GitHub's file size limit of 100.00 MB
remote: error: File app/release/app-release.apk is 105.54 MB; this exceeds GitHub's file size limit of 100.00 MB
To https://github.com/montao/adventure.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/montao/adventure.git'

 git status
On branch master
Your branch is ahead of 'origin/master' by 8 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

Upvotes: 6

Views: 11434

Answers (2)

Roland Smith
Roland Smith

Reputation: 43533

At one point, I committed a bunch of full-sized photos to a repo of mine. The following is what I did to completely remove them from the history.

First, I made a copy of the repo. So I had a backup in case I screwed something up. Best not to skip this step. :-)

Then I did an interactive rebase (rebase -i) from just before the original commit where I accidentally added the photos. I dropped the commit of the photos.

After the rebase, I ran

git reflog expire --expire=now --all
git gc --aggressive --prune=now

In your case, also add app/releases/ to your .gitignore.

Upvotes: 5

Axnyff
Axnyff

Reputation: 9964

You can simply reset your state and not include the apk file (you probably should not commit them).

You can simply do

git reset origin/master

To keep your changes but reset all of your commits.

Upvotes: 14

Related Questions