Skip to content

Instantly share code, notes, and snippets.

@lesleh
Last active August 29, 2015 14:22
Show Gist options
  • Save lesleh/673331fccb1d0cd7d997 to your computer and use it in GitHub Desktop.
Save lesleh/673331fccb1d0cd7d997 to your computer and use it in GitHub Desktop.
Run command on all Git repositories in current directory.
#!/bin/bash
# Example usage: ./each_repo.sh 'git pull'
if [ $# -ne 1 ]; then
2>&1 echo "No command specified."
exit 1
fi
DIR=$(pwd) # $(dirname $(readlink -f $0))
COMMAND=$1
find $DIR -maxdepth 2 -mindepth 2 -name .git -type d | while read REPO; do
REPO=${REPO//.git/}
echo $REPO
pushd $REPO >/dev/null
eval $COMMAND
popd >/dev/null
echo
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment