We inadvertently pushed a lot of binary files (images ...) to our BitBucket repository causing it now to be about 1.5GB in size. We now want to remove those files such that they're "really, really gone" and the size of our repo is back down where it should be. Will git rm
actually do this, or simply make the files inaccessible to subsequent git pull
? We want to physically remove these files from the repo altogether ... "really gone for good."
Asked
Active
Viewed 41 times
-2

Mike Robinson
- 8,490
- 5
- 28
- 41
-
2https://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository – Mickael B. Jan 07 '20 at 20:23
-
2Does this answer your question? [How to remove/delete a large file from commit history in Git repository?](https://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository) – jonrsharpe Jan 07 '20 at 20:31
1 Answers
1
To truly remove files you must obliterate them from history. This requires rewriting history. You can use git-filter-branch
, but it's much easier to use the BFG Repo Cleaner. For example, to remove all files bigger than 100 megs...
java -jar bfg.jar --strip-blobs-bigger-than 100M some-big-repo.git
This means those files never happened. There will be no record of them in the repository history.
If you want to keep your big files, use Git Large File Storage (git-lfs
). This stores a record of big files in your repository history, but the files themselves are retrieved on demand keeping the repository slim. And for existing files you can use the BFG to migrate large files to Git LFS.

Schwern
- 153,029
- 25
- 195
- 336