gitgithubgit-lfs

How to delete a file tracked by git-lfs and release the storage quota?


How to delete a never-use-again file and release the storage back to the github lfs quota?

Does deleting the reference point of the file in git history work in this situation?


Solution

  • There doesn't currently appear to be a great way of removing large assets from git-lfs. GitHub's current suggestion is to use a tool called The BFG to completely strip all existence of the file from your repo.

    Presumably it'll then be removed from the lfs storage when git's garbage collection is next run by GitHub.

    For more info see https://help.github.com/en/github/managing-large-files/removing-files-from-git-large-file-storage

    Edit 2019-11-20

    GitHub has updated their documentation on this explicitly stating there is no way to free up your git-lfs storage without deleting your repository. https://help.github.com/en/github/managing-large-files/removing-files-from-git-large-file-storage

    Their only recommendation is to still use the BFG tool to strip the file from your repository, which will reduce the size of your repository when cloning, but will still count towards your git-lfs quota until you delete the repository.

    GitLab again suggests using the BFG tool and will automatically clean the lfs storage of any files which aren't referenced in any commits, although currently this doesn't seem to be working correctly. This issue has been open since 2017 with no resolution.

    BitBucket has a section in the repository settings which you can clean up lfs files. https://www.atlassian.com/git/tutorials/git-lfs#deleting-remote-files