Skip to content

Instantly share code, notes, and snippets.

@kas-cor
Last active January 29, 2021 22:54
Show Gist options
  • Save kas-cor/1b3f36e4f0256ce9280ad37640e6cd93 to your computer and use it in GitHub Desktop.
Save kas-cor/1b3f36e4f0256ce9280ad37640e6cd93 to your computer and use it in GitHub Desktop.
Finding and optimize repositories in current directory
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
@kas-cor
Copy link
Author

kas-cor commented Jan 29, 2021

Install

wget -O - https://git.io/Jt8xs >> ./optimize_repositories.sh && chmod u+x ./optimize_repositories.sh

Use

./optimize_repositories.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment