Skip to content

Instantly share code, notes, and snippets.

@lidedongsn
Created May 8, 2019 09:22
Show Gist options
  • Save lidedongsn/3d3bd7f8fc9985798ff6c18cd6bca59a to your computer and use it in GitHub Desktop.
Save lidedongsn/3d3bd7f8fc9985798ff6c18cd6bca59a to your computer and use it in GitHub Desktop.
扫描目录下所有git库,并执行相应的操作
#!/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