Skip to content

Instantly share code, notes, and snippets.

@chainat
Last active May 28, 2022 20:07
Show Gist options
  • Save chainat/e2d4d806b8b1a3ddb6d5b8400e1e30ea to your computer and use it in GitHub Desktop.
Save chainat/e2d4d806b8b1a3ddb6d5b8400e1e30ea to your computer and use it in GitHub Desktop.
Compact local git repo
These two commands will minimise the diskspace used for the repo. Please note that Github, BitBucket run this all the time to minimise the diskspace.
Suggestion: Run as often as you can (i.e. once a week for small working-in-progress repo, one in every few days if many people work together).
It's no harm to run it often, cron or system task could be an option too.
# Clean unused commits
`git reflog expire --all --expire=now`
# Compact the disk by remove unneccesary files from the local git repository
`git gc --aggressive --prune=now`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment