Maybe it's too late to post a reply, but as this page is the first Google's result, it may still be helpful.
If you want to free some space in your git repo, but do not want to rebuild all your commits (rebase or graft), and still be able to push/pull/merge from people who has the full repo, you may use the git clone shallow clone (--depth parameter).
; Clone the original repo into limitedRepo
git clone file:///path_to/originalRepo limitedRepo --depth=10
; Remove the original repo, to free up some space
rm -rf originalRepo
cd limitedRepo
git remote rm origin
You may be able to shallow your existing repo, by following these steps:
; Shallow to last 5 commits
git rev-parse HEAD~5 > .git/shallow
; Manually remove all other branches, tags and remotes that refers to old commits
; Prune unreachable objects
git fsck --unreachable ; Will show you the list of what will be deleted
git gc --prune=now ; Will actually delete your data
How to remove all git local tags?
Ps: Older versions of git didn't support clone/push/pull from/to shallow repos.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…