Skip to content

Instantly share code, notes, and snippets.

@ekosuhariyadi
Created February 28, 2015 04:11
Show Gist options
  • Save ekosuhariyadi/8fc6c8ae9e8158dde289 to your computer and use it in GitHub Desktop.
Save ekosuhariyadi/8fc6c8ae9e8158dde289 to your computer and use it in GitHub Desktop.
recursive git pull in a directory
#!/bin/bash
src="."
for dir in `ls "$src/"`;
do
if [[ -d "$src/$dir" ]]; then
echo -e "Checking update for $dir ... start";
(cd "$dir" && git pull);
echo -e "Checking update for $dir ... done\n\n";
fi
done
@ekosuhariyadi
Copy link
Author

#another style using find
CURRENT_DIR=$PWD;

for dir in $(find $CURRENT_DIR -mindepth 1 -maxdepth 1 -type d);
do
echo "Updating $dir";
cd $dir;
git pull;
done
cd $CURRENT_DIR;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment