Skip to content

Instantly share code, notes, and snippets.

@finscn
Last active May 5, 2019 07:32
Show Gist options
  • Save finscn/0c721fd5b45766299dd804552cd6a8af to your computer and use it in GitHub Desktop.
Save finscn/0c721fd5b45766299dd804552cd6a8af to your computer and use it in GitHub Desktop.
update local git repositories in directory
#!/bin/bash
CURRENT=$PWD
echo $CURRENT
function ergodic(){
if [ -n "$1" ] ;then
echo '>>>>>> ENTER [' $1 '] >>>>>>'
cd $1
else
cd .
fi
for dir in `ls .`
do
if [ -d $dir'/.git' ]
then
cd $dir
echo '========' $dir '========'
git pull
cd ..
elif [[ $dir == _* ]]
then
ergodic $dir
fi
done
if [ -n "$1" ] ;then
echo '<<<<<< EXIT [' $1 '] <<<<<<'
cd ..
fi
}
IFS=$'\n' #这个必须要,否则会在文件名中有空格时出错
ergodic $1
cd $CURRENT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment