Reducing git repo size resulting from now-deleted files
During the history of my git repo, there were lots of media binary files added to it. Now those media files have been deleted.
However, I suspect that the repo is storing information of those media files in the repo's archive, as my repo size is 400MB.
I've read about clean-up com开发者_如何学JAVAmands such as git-gc --aggressive
but I don't think that allows me to directly "forget" those old media files.
P.S. - those media files were actually part of an SVN repo at the time, and I have since used git-svn to convert the repo to git.
If they're part of any of your branches' history then git needs to store those files' contents, otherwise you would have an incomplete history.
The only way to completely remove them would be to rewrite those branches' history and remove them from the commits where they were added and onwards until they were removed.
My initial advice would be to not worry about them. They won't ever change now, so other than the initial clone and the repository size they won't have any other performance effects on operations on the tip of the current branches.
If you do decided to rewrite your repository's history you probably need to look at something like git filter-branch
with either --index-filter
or --tree-filter
.
Note that anyone with active work built on the current repository with active work will have to be careful to do an appropriate rebase operation or risk merging in all the old commits and bringing back the objects that you are trying to get rid of.
精彩评论