批量clone仓库代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash

code_addr=(
'git@gitlab.com:project/project1.git'
'git@gitlab.com:project/project2.git'
'git@gitlab.com:project/project3.git'
)
website_dir=website
clone_code(){
#判断文件夹是否存在
if [ -d $website_dir ];then
echo "文件夹存在"
cd $website_dir
else
echo "文件不存在,创建$website_dir文件夹"
mkdir $website_dir && cd $website_dir
fi
#批量克隆项目代码
for i in ${code_addr[@]}
do
git clone $i
done
}
clone_code
echo "website项目组已拉取完毕!"

批量拉取代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

project_pull(){
cd /data/gitlab/project/
for dir in `ls`;do
if [ -d $dir ];then
cd $dir
git pull origin master;
echo "$dir 更新完毕!"
cd ..
sleep 1
else
echo "此文件不是目录"
fi
done
}

project_pull
echo "project项目组已全部更新"
cd ..