Created
February 21, 2016 06:54
-
-
Save shionryuu/dd0b8ae653fb1333bfce to your computer and use it in GitHub Desktop.
pull all git repositories in a directory
This file contains 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 | |
# pull all git repositories in a directory | |
pull_repo() { | |
echo "pulling $1 ..." | |
if git pull; then # >/dev/null 2>&1 | |
echo -e "pulling $1 succeed\n" | |
else | |
echo -e "pulling $1 failed\n" | |
fi | |
} | |
pull_dir() { | |
for dir in `ls` | |
do | |
proj=$(basename $dir) | |
if [[ -d $dir/.git ]]; then | |
cd $dir | |
pull_repo $proj | |
cd .. | |
elif [[ -d $dir ]]; then | |
echo "pull $dir recursively" | |
cd $dir | |
pull_dir | |
cd .. | |
fi | |
done | |
} | |
if [[ $# > 0 ]]; then | |
for dir in $@ | |
do | |
if [[ -d $dir ]]; then | |
cd $dir | |
pull_dir | |
fi | |
done | |
else | |
pull_dir | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment