0

I have created a project on my local machine and configured a remote repository to which I want to push. When trying to push my code, there was an error and that was due to a file whose size was very large. I hence deleted the file from my local machine using the rm -f <filename> command. I then ran the git rm <filename> and added the changes to the staging area and later committed the changes.

Now, when I try to push the changes to the remote, I am getting the same error stating the file size is huge. I dont have the file on my workspace and moreover, the git status command shows that the workspace is clean. Also the git log command shows that the deletion of the file is committed. Could you please let me know how to troubleshoot and where I am going wrong. Also how to fix the issue.

zilcuanu
  • 3,451
  • 8
  • 52
  • 105

1 Answers1

1

The huge file is still in your Git history. You need to remove it, not just from the repo, but from the Git history. https://rtyley.github.io/bfg-repo-cleaner/ will help (see How to remove/delete a large file from commit history in Git repository? for someone else who had the same problem). Summary:

  1. Clone your repo and work on the clone (so you have a backup of your original if something goes wrong): git clone --mirror /path/to/your/repo cloned-repo-to-trim
  2. Follow the BFG usage instructions to strip out large files (something like java -jar bfg.jar --strip-blobs-bigger-than 100M cloned-repo-to-trim).
  3. Run git gc --prune=now --aggressive in the cloned repo to get rid of the large commits permanently.
  4. Verify the cloned repo still has all the other commits it should have, then push it to your remote.

Hope this helps.

Community
  • 1
  • 1
rmunn
  • 34,942
  • 10
  • 74
  • 105
  • Caveat: If he really needs some of those big files, then he should not be removing them. In this case, the options would be switching to a repository service which allows large files, such as BitBucket, or possibly considering moving a portion of the code base out of Git and into another VCS tool. – Tim Biegeleisen Oct 30 '15 at 05:45