Reputation: 33
I'm having trouble with a git repository (that is, a GitHub repo to which I push via git command-line tool).
It is a Rails app. One of the functionalities it implements is the download of .zip files... Which, by design, are created and temporarily stored on the server (localhost). Problem is the auto-delete hasn't been implemented yet. So, with .zip files around 120MB in size on the "server", I decided to git add -A
, git commit -m "blabla"
and git push
. Pushing took forever, ending up in an error message along the lines of "the file is too big, push aborted".
I gave up on pushing that day and deleted the problematic file instead. I kept on working the next days, opened a new branch, checked back out to branch master, tried to add -> commit -> push but... The error message about the size-exceeding .zip file was still there!
What's going on?!
Please help me out!
Upvotes: 3
Views: 2438
Reputation: 308
When you ran git add; git commit
then git added the zip file to your local repository. Even though you deleted the local file, git still has it in the repo since it keeps a copy of every file ever committed.
Since you've already committed the file to your local git repo, you'll need to remove it from the history before you can push. In order to do that, follow this answer: https://stackoverflow.com/a/2158271/1695439
The answer boils down to running git filter-branch
and then deleting your original branch. Remember to replace giantfile.zip with the filename of your giant zip file.
$ git filter-branch --index-filter 'git rm --cached -r --ignore-unmatch giantfile.zip' --prune-empty --tag-name-filter cat -- --all
$ git update-ref -d refs/original/refs/heads/master
$ git reflog expire --expire=now --all
$ git gc --prune=now
Upvotes: 4