Skip to content

Instantly share code, notes, and snippets.

@shionryuu
Created February 21, 2016 06:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shionryuu/dd0b8ae653fb1333bfce to your computer and use it in GitHub Desktop.
Save shionryuu/dd0b8ae653fb1333bfce to your computer and use it in GitHub Desktop.
pull all git repositories in a directory
#!/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