1、在预装好GIT环境下执行
第三方工具官网
轻松几部拯救臃肿的仓库
2、 以下为官方实例:
Usage
First clone a fresh copy of your repo, using the --mirror flag:
This is a bare repo, which means your normal files won't be visible, but it is a full copy of the Git database of your repository, and at this point you should make a backup of it to ensure you don't lose anything.
Now you can run the BFG to clean your repository up:
The BFG will update your commits and all branches and tags so they are clean, but it doesn't physically delete the unwanted stuff. Examine the repo to make sure your history has been updated, and then use the standard git gc command to strip out the unwanted dirty data, which Git will now recognise as surplus to requirements:
Finally, once you're happy with the updated state of your repo, push it back up (note that because your clone command used the --mirror flag, this push will update all refs on your remote server):
At this point, you're ready for everyone to ditch their old copies of the repo and do fresh clones of the nice, new pristine data. It's best to delete all old clones, as they'll have dirty history that you don't want to risk pushing back into your newly cleaned repo.
更高级用法请参考参考官网说明:https://rtyley.github.io/bfg-repo-cleaner/。官网首页有简单的示例介绍。