Last active
May 5, 2019 07:32
-
-
Save finscn/0c721fd5b45766299dd804552cd6a8af to your computer and use it in GitHub Desktop.
update local git repositories in 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 | |
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