参数1:1:克隆分支 2:更新分支 3:切换分支 4:拷贝代码
if_git_pull_or_checkoutBranch=$1
##参数2: 复深蓝代码分支
fulan_branch=$2
##参数2: 项目名称
project_name=$2
##参数3: 上海证券代码分支
securities_branch=$3
#复深蓝代码路径
fulanlinuxPath=‘/d/git-work/fulan’;
上海证券代码路径
securitieslinuxPath=‘/d/git-work/sh-securities’;
#开启扩展通配符
shopt -s extglob
##参数2: 复深蓝代码分支
fulan_branch1=$2
fulan_branch2=$3
fulanArrays=(
‘cloud-base’
‘cloud-knowledge’
‘cloud-xxljob-client’
‘cloud-system’
‘cloud-workflow’
‘cloud-gateway’
‘cloud-parent’
‘cloud-people’
‘cloud-project’
‘front-pc’
‘front-manage’
‘front-h5’
)
# 克隆分支
if [ $if_git_pull_or_checkoutBranch -eq 1 ]; then
rm -rf $securitieslinuxPath/*
f
u
l
a
n
l
i
n
u
x
P
a
t
h
/
∗
f
o
r
v
a
l
u
e
i
n
"
fulanlinuxPath/* for value in "
fulanlinuxPath/∗forvaluein"{fulanArrays[@]}"
do
cd $fulanlinuxPath
if [[ $value =~ 'front' ]]
then git clone http://git.biandejun.com/sh-securities-group/front-space/$value.git
else git clone http://git.biandejun.com/sh-securities-group/$value.git
fi
cp -r ls | grep -v .git | xargs linuxPath
cd $securitieslinuxPath
git clone http://10.4.2.100:31101/app_dev/mss/$value.git
done
更新分支
elif [ $if_git_pull_or_checkoutBranch -eq 2 ]; then
#开启模式匹配功能
shopt -s extglob
for value in “${fulanArrays[@]}”
do
cd $fulanlinuxPath
cd $value
git pull
echo -e “\033[0;32m git pull 复深蓝 path =
f
u
l
a
n
l
i
n
u
x
P
a
t
h
/
fulanlinuxPath/
fulanlinuxPath/value \033[0m”
cd $securitieslinuxPath
cd $value
git pull
echo -e “\033[0;36m git pull 上海证券 path =
s
e
c
u
r
i
t
i
e
s
l
i
n
u
x
P
a
t
h
/
securitieslinuxPath/
securitieslinuxPath/value \033[0m”
done
# 切换分支 复深蓝代码分支 上海证券代码分支
elif [ $if_git_pull_or_checkoutBranch -eq 3 ]; then
for value in "${fulanArrays[@]}"
do
cd $fulanlinuxPath
cd $value
git fetch
git pull
git checkout $fulan_branch
git pull
echo -e "\033[0;32m git checkout 复深蓝 $value branch $fulan_branch \033[0m"
cd $securitieslinuxPath
cd $value
git fetch
git pull
git checkout $securities_branch
git pull
echo -e "\033[0;36m git checkout 上海证券 $value branch $securities_branch \033[0m"
done
# 拷贝所有代码
elif [ $if_git_pull_or_checkoutBranch -eq 4 ]; then
for value in "${fulanArrays[@]}"
do
cd $fulanlinuxPath
cd $value
git pull
echo -e "\033[0;36m pull 复深蓝 $value \033[0m"
cd $securitieslinuxPath
cd $value
echo -e "\033[0;36m pull 上证 $value \033[0m"
#cloud-parent工程pom.xml手动管理
if [[ $value =~ 'parent' ]]
then ls $fulanlinuxPath/$value/ | grep -v 'pom.xml\|.git' | xargs -i cp -rf $fulanlinuxPath/$value/{} $securitieslinuxPath/$value/
#前端工程除了.git全部替换
elif [[ $value =~ 'front' ]]
then
rm -rf !(.git)
ls -A $fulanlinuxPath/$value/ | grep -v '.git' | xargs -i cp -rf $fulanlinuxPath/$value/{} $securitieslinuxPath/$value/
#后端工程删除替换指定文件/目录
else
rm -rf Dockerfile pom.xml src
ls $fulanlinuxPath/$value/ | grep -v '.git' | xargs -i cp -rf $fulanlinuxPath/$value/{} $securitieslinuxPath/$value/
fi
echo -e "\033[0;36m ls $fulanlinuxPath/$value/ | grep -v '.git' | xargs -i cp -r $fulanlinuxPath/$value/{} $securitieslinuxPath/$value/ \033[0m"
cd $securitieslinuxPath
cd $value
git pull
ls -all
git add .
git commit -m "fsl合并代码 `date` "
git push
done
# 拷贝单个代码
elif [ $if_git_pull_or_checkoutBranch -eq 5 ]; then
cd $fulanlinuxPath
echo -e "\033[0;36m cd $fulanlinuxPath \033[0m"
cd $project_name
echo -e "\033[0;36m cd $project_name \033[0m"
basepath=$(pwd)
echo -e "\033[0;36m 当前路径:$basepath \033[0m"
git pull
echo -e "\033[0;36m pull 复深蓝 $project_name \033[0m"
## rm -rf Dockerfile pom.xml src
cd $securitieslinuxPath
echo -e "\033[0;36m cd $securitieslinuxPath \033[0m"
cd $project_name
echo -e "\033[0;36m cd $project_name \033[0m"
basepath=$(pwd)
echo -e "\033[0;36m 当前路径:$basepath \033[0m"
git pull
echo -e "\033[0;36m pull 上海证券 $project_name \033[0m"
if [[ $project_name =~ 'parent' ]]
then ls $fulanlinuxPath/$project_name/ | grep -v 'pom.xml\|.git' | xargs -i cp -rf $fulanlinuxPath/$project_name/{} $securitieslinuxPath/$project_name/
echo -e "\033[0;36m parent服务特殊处理 \033[0m"
elif [[ $project_name =~ 'front' ]]
then ls -A $fulanlinuxPath/$project_name/ | grep -v '.git\|public' | xargs -i cp -rf $fulanlinuxPath/$project_name/{} $securitieslinuxPath/$project_name/
echo -e "\033[0;36m 前端服务特殊处理 \033[0m"
else
ls $fulanlinuxPath/$project_name/ | grep -v '.git' | xargs -i cp -rf $fulanlinuxPath/$project_name/{} $securitieslinuxPath/$project_name/
echo -e "\033[0;36m 普通服务 \033[0m"
fi
echo -e "\033[0;36m ls $fulanlinuxPath/$project_name/ | grep -v '.git' | xargs -i cp -r $fulanlinuxPath/$project_name/{} $securitieslinuxPath/$project_name/ \033[0m"
cd $securitieslinuxPath
echo -e "\033[0;36m cd $securitieslinuxPath \033[0m"
cd $project_name
echo -e "\033[0;36m cd $project_name \033[0m"
ls -all
git add .
git commit -m 'fsl合并代码'
git push
#合并分支 把复深蓝分支$fulan_branch1 往分支$fulan_branch2上合并
elif [ KaTeX parse error: Undefined control sequence: \0 at position 56: …hen echo -e "\̲0̲33[0;36m 当前参数:fulan_branch1 $fulan_branch2 \033[0m"
for value in " ${fulanArrays[@]}"
do
cd $fulanlinuxPath
cd $value
basepath=$(pwd)
echo -e "\033[0;36m 当前路径:$basepath \033[0m"
git checkout $fulan_branch1
git pull
echo -e "\033[0;32m git pull fulan path = $fulanlinuxPath/$value sourebranch: $fulan_branch1 targetbranch: $fulan_branch2 \033[0m"
git checkout $fulan_branch2
git pull
git merge $fulan_branch1
git push -u origin $fulan_branch2
echo -e "\033[0;32m 分支 $fulan_branch1 往分支$fulan_branch2 上合并 git merge fulan path = $fulanlinuxPath/$value \033[0m"
done
#合并分支 把上海证券分支$fulan_branch1 往分支$fulan_branch2上合并
elif [ KaTeX parse error: Undefined control sequence: \0 at position 56: …hen echo -e "\̲0̲33[0;36m 当前参数:fulan_branch1 $fulan_branch2 \033[0m"
for value in " ${fulanArrays[@]}"
do
cd $securitieslinuxPath
cd $value
basepath=$(pwd)
echo -e "\033[0;36m 当前路径:$basepath \033[0m"
git checkout $fulan_branch1
git pull
echo -e "\033[0;32m git pull fulan path = $securitieslinuxPath/$value sourebranch: $fulan_branch1 targetbranch: $fulan_branch2 \033[0m"
git checkout $fulan_branch2
git pull
git merge $fulan_branch1
git push -u origin $fulan_branch2
echo -e "\033[0;32m 分支 $fulan_branch1 往分支$fulan_branch2 上合并 git merge fulan path = $securitieslinuxPath/$value \033[0m"
done
fi
克隆代码
#./fulan-dh-git.sh 1
更新代码
#./XXX.sh 2
切换分支 dev(上海人寿分支) sit(深蓝云校分支)
#./XXX.sh 3 dev sit文章来源:https://www.toymoban.com/news/detail-845732.html
拷贝代码
#./XXX.sh 4文章来源地址https://www.toymoban.com/news/detail-845732.html
到了这里,关于git 不同仓库 同步的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!