Skip to content

Instantly share code, notes, and snippets.

@shibukawa
Created April 26, 2013 01:28
Show Gist options
  • Save shibukawa/5464537 to your computer and use it in GitHub Desktop.
Save shibukawa/5464537 to your computer and use it in GitHub Desktop.
Defrag command for Mac OS/Linux
#! /bin/bash
# based on http://goingmyway.net/?p=632
#
# check depend commands
#
_dependCommands="git expect"
for _COMMAND in ${_dependCommands}; do
if [ ! `whereis ${_COMMAND} |grep ${_COMMAND}` ]; then
echo "ERROR!! 必要なコマンドが見つかりません : ${_COMMAND}"
exit 1
fi
done
#
# Get git dirs
#
_GITDIRS=`find . -name ".git" | sed "s/\(\.\/.*\)\/.git/\1/g"`
#
# Clean git dirs
#
for _DIRS in ${_GITDIRS}; do
echo -e "\n -- ${_DIRS} -- ";
cd $_DIRS;
git gc;
cd ../
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment