Git purge local branches that were deleted on remote
$> git remote prune origin
This will cleanup local branches.
You may also want to cleanup and compact your repo
WARNING: This may temporarily use twice as disk space so do not use if you don't have enough free space
git reflog expire --all --expire=now
git gc --prune=now --aggressive
If it fails due to missing disk space, it won't cleanup and will leave your disk 100% full. You then have to do
rm -f .git/objects/*/tmp_*
If you set this up as an automated task, you might want to cleanup automatically on failure with something like
git gc || rm -f .git/objects/*/tmp_*
Troubleshooting
$> git gc --prune=now --aggressive
Counting objects: 556318, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (542764/542764), done.
fatal: sha1 file '.git/objects/pack/tmp_pack_OBQCK7' write error: No space left on device
error: failed to run repack
Solution
rm -f .git/objects/*/tmp_*
Recent Comments