Last active
August 29, 2015 14:22
-
-
Save lesleh/673331fccb1d0cd7d997 to your computer and use it in GitHub Desktop.
Run command on all Git repositories in current directory.
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 | |
# 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