Update a development team with rewritten Git repo history, removing big files

后端 未结 4 1251
盖世英雄少女心
盖世英雄少女心 2020-12-01 05:29

I have a git repo with some very large binaries in it. I no longer need them, and I don\'t care about being able to checkout the files from earlier commits. So, to reduce th

4条回答
  •  广开言路
    2020-12-01 06:10

    Your plan is good (though it would be better to perform the filtering on a bare clone of your repository, rather than on the central server), but in preference to git-filter-branch you should use my BFG Repo-Cleaner, a faster, simpler alternative to git-filter-branch designed specifically for removing large files from Git repos.

    Download the Java jar (requires Java 6 or above) and run this command:

    $ java -jar bfg.jar  --strip-blobs-bigger-than 1MB  my-repo.git
    

    Any blob over 1MB in size (that isn't in your latest commit) will be totally removed from your repository's history. You can then use git gc to clean away the dead data:

    $ git gc --prune=now --aggressive
    

    The BFG is typically 10-50x faster than running git-filter-branch and the options are tailored around these two common use-cases:

    • Removing Crazy Big Files
    • Removing Passwords, Credentials & other Private data

提交回复
热议问题