0

I mistakenly committed a 300 MB file into a git repository, then pushed to Github and got a message that the file is too large.

So I deleted the file as instructed here: https://help.github.com/articles/working-with-large-files

git rm --cached giant_file
git commit --amend -CHEAD

but got the same error:

remote: error: File giant_file is 313.04 MB; this exceeds GitHub's file size limit of 100 MB

I tried to remove the file again, but got the error:

$ git rm --cached giant_file
fatal: pathspec 'giant_file' did not match any files

How can I get rid of this huge file?

Erel Segal-Halevi
  • 33,955
  • 36
  • 114
  • 183
  • possible duplicate of [Completely remove files from Git repo and remote on GitHub](http://stackoverflow.com/questions/5563564/completely-remove-files-from-git-repo-and-remote-on-github) – sleske Apr 23 '14 at 07:12
  • Thanks, the first answer there solved my problem. – Erel Segal-Halevi Apr 26 '14 at 20:37

1 Answers1

0

Since the push failed on the account of the giant_file, the changes are still local in your repository. Creating a new commit that removes the file doesn't delete the file from the branch history (tree of commits) and that's why the push of the branch with the commit that removes the file fails.

The simplest way to remove the file is to git reset the branch to the parent of the change where you added the file, and recreate the commit anew without the giant_file. After you've reset and re-committed you should be able to push to the remote.

mockinterface
  • 14,452
  • 5
  • 28
  • 49