How to remove old versions of media files from a git repository

后端 未结 5 458
不思量自难忘°
不思量自难忘° 2020-12-15 05:00

I have a Git repository with several huge media files (images and audio files). Several versions of these media files have been successively commited to the repo. The files

5条回答
  •  难免孤独
    2020-12-15 05:25

    As mentioned already, you will be re-writing history here, so you will have to get collaborators (if any) to do git rebase.

    As for stripping a particular file from history, Github has a nice walkthrough.

    For a solution going forward, you should look at putting the binary files in a sub-module.

    Git's submodule support allows a repository to contain, as a subdirectory, a checkout of an external project. Submodules maintain their own identity; the submodule support just stores the submodule repository location and commit ID, so other developers who clone the containing project ("superproject") can easily clone all the submodules at the same revision. Partial checkouts of the superproject are possible: you can tell Git to clone none, some or all of the submodules.

    https://git-scm.com/docs/git-submodule

    https://git-scm.com/book/en/v2/Git-Tools-Submodules

提交回复
热议问题