current_dir=$PWD echo "Finding repositories in $current_dir" && echo for repo in `find ${current_dir} | grep ".git$"` do echo "Repository ${repo%.git} size `du -hcs ${repo} | grep 'total\|итого'`" cd ${repo%.git} && git gc > /dev/null 2>&1 echo "Size after optimization `du -hcs ${repo} | grep 'total\|итого'`" && echo cd ${current_dir} done