Search code examples
gitgit-squash

Git squash commits to reduce space by zip files


I am dealing with a repo that for reasons I can't do anything about have zip files that get to few mb and often change with each commit. I understand that means git is storing a complete copy of each zip for each commit, rather than deltas.

We are working with feature branches. If I squash commits in a feature branch before merging to master, will that reduce the space taken by all those zips?


Solution

  • It will reduce the size because only the latest zip file makes it in to master. Just be sure to delete any remote branches you have created that contain multiple versions of the zip file scattered throughout multiple commits.

    Locally, delete the source branch and run git gc to remove commit objects that are no longer referenced by a branch, which should clean up unused copies of the zip files as well.