Cleaning up git repos


Notes on git cleaning

This can be a good idea for packages that needs to load fast. And where the history of commits doesnt matter or can be reset to init because the initial development isn’t important to preserve.

A 11 MB repo went to 10mb with these commands:

There will be nothing to commit 🤔

git gc --aggressive --prune=now

Squashing could be a solution

  • But won’t work if there are merge commits

Reset history:

Alternative:

git init
git add .
git commit -m 'Initial commit'
git remote add origin [repo_address]
git push --mirror --force