Created
May 8, 2019 09:22
-
-
Save lidedongsn/3d3bd7f8fc9985798ff6c18cd6bca59a to your computer and use it in GitHub Desktop.
扫描目录下所有git库,并执行相应的操作
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 | |
function getdir(){ | |
for element in `ls $1` | |
do | |
dir_or_file=$1"/"$element | |
if [ -d $dir_or_file ] | |
then | |
# echo $dir_or_file | |
if [ -d $dir_or_file/.git ] | |
then | |
echo $dir_or_file | |
cd $dir_or_file | |
git reset --hard #可以执行想要的git操作 | |
cd - | |
fi | |
getdir $dir_or_file | |
#else | |
#echo $dir_or_file | |
fi | |
done | |
} | |
getdir $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment