How to remove unreferenced blobs from my git repo

后端 未结 10 2361
轻奢々
轻奢々 2020-11-22 15:07

I have a GitHub repo that had two branches - master & release.

The release branch contained binary distribution files that were contributing to a very large repo

10条回答
  •  深忆病人
    2020-11-22 15:18

    ... and without further ado, may I present to you this useful command, "git-gc-all", guaranteed to remove all your git garbage until they might come up extra config variables:

    git -c gc.reflogExpire=0 -c gc.reflogExpireUnreachable=0 -c gc.rerereresolved=0 -c gc.rerereunresolved=0 -c gc.pruneExpire=now gc
    

    You might also need to run something like these first, oh dear, git is complicated!!

    git remote rm origin
    rm -rf .git/refs/original/ .git/refs/remotes/ .git/*_HEAD .git/logs/
    git for-each-ref --format="%(refname)" refs/original/ | xargs -n1 --no-run-if-empty git update-ref -d
    

    You might also need to remove some tags, thanks Zitrax:

    git tag | xargs git tag -d
    

    I put all this in a script: git-gc-all-ferocious.

提交回复
热议问题