Created
September 8, 2016 18:38
-
-
Save jdforsythe/49c900e84835fb3153abd49e7d4360be to your computer and use it in GitHub Desktop.
Git Maintenance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo "Cleaning git merge conflict artifacts..." | |
find . -name "*.bak" | while read filename; do echo "Removing: $filename" && rm -rf "$filename"; done | |
echo -e "\n" | |
echo "Counting unreachable objects in git database..." | |
unreachable=$(git fsck --unreachable | wc -l) | |
echo "There are $unreachable unreachable objects." | |
if [ $unreachable -gt 0 ]; then | |
echo "Cleaning unreachable objects.." | |
git prune | |
fi | |
echo -e "\n" | |
echo "Packing unpacked objects..." | |
git repack -a -d -l | |
echo -e "\n" | |
echo "Forcing garbage collection..." | |
git gc --aggressive | |
echo -e "\n" | |
echo "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment