get_origin_all显示本目录下所有项目git地址
#!/bin/sh
## get_origin_all.sh
##This bash file can update all git project in given directory
#in case this file being invoked form other path
base_dir=$(dirname "$0")
#a tool script for colorful output
cd $base_dir
#read given directory as repositories directory,
#or current directory
project_dir="."
if [ ! -z $1 ]
then
project_dir=$1
fi
if [ ! -d $project_dir ]
then
echo "$project_dir is not a directory."
exit 1
fi
echo "Set repository base directory to $project_dir"
for project in `ls $project_dir`
do
if [ -d $project ]
then
cd $project
#update git repository
if [ -d '.git' ]
then
#echo "Updating project:$project"
#git pull
git remote show origin|grep Fetch
#echo "Done."
echo
#update svn repository
elif [ -d '.svn' ]
then
echo "Updating project:$project"
svn update
echo "Done."
echo
else
echo "$project is not a repository.\n"
fi
cd ..
fi
done
echo "Finished..."
read
exit 0
git_pull_all本目录下所有项目git pull
#!/bin/sh
## git_pull_all.sh
##This bash file can update all git project in given directory
#in case this file being invoked form other path
base_dir=$(dirname "$0")
#a tool script for colorful output
cd $base_dir
#read given directory as repositories directory,
#or current directory
project_dir="."
if [ ! -z $1 ]
then
project_dir=$1
fi
if [ ! -d $project_dir ]
then
echo "$project_dir is not a directory."
exit 1
fi
echo "Set repository base directory to $project_dir"
for project in `ls $project_dir`
do
if [ -d $project ]
then
cd $project
#update git repository
if [ -d '.git' ]
then
echo "Updating project:$project"
git pull
echo "Done."
echo
#update svn repository
elif [ -d '.svn' ]
then
echo "Updating project:$project"
svn update
echo "Done."
echo
else
echo "$project is not a repository.\n"
fi
cd ..
fi
done
exit 0
clone_all按git地址列表批量clone项目到本地
#!/bin/sh
## clone_all.sh
echo "Start..."
git clone ssh://git@git.example.com/Test1.git
git clone ssh://git@git.example.com/Test2.git
echo "Finished..."
read
exit 0
网友评论