We often get to a point where we have billions of local git repositories that have been merged already, or abandoned - it’s often difficult to see the wood from the trees.
Prune remote tracking branches
git fetch --prune
This only deletes the remote references to these branches,
if they have been deleted on origin
- it doesn’t delete them locally.
It does however clean-up views you get of the current code, and removes some git cruft locally.
Delete local branches that have been merged
git branch -d $(git branch --merged=master | grep -v master)
Since master
merges into itself, we need to exclude it from the run.
Garbage collect loose ends
git gc
Read more about git gc
here.
A simple run through of any unreferenced objects and unnecessary files to speed up merges and pushes.
You’re supposed to run this ‘regularly’, apparently…