git 不同仓库 同步

参数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

拷贝代码

#./XXX.sh 4

相关推荐

  1. git 不同仓库 同步

    2024-03-21 16:26:01       40 阅读
  2. git 不同远程仓库合并

    2024-03-21 16:26:01       42 阅读
  3. git 派生仓库怎么同步仓库的新分支

    2024-03-21 16:26:01       35 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-03-21 16:26:01       98 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-03-21 16:26:01       106 阅读
  3. 在Django里面运行非项目文件

    2024-03-21 16:26:01       87 阅读
  4. Python语言-面向对象

    2024-03-21 16:26:01       96 阅读

热门阅读

  1. Webapi 日志过滤器(接口日志记录)

    2024-03-21 16:26:01       37 阅读
  2. C++ 类构造函数 & 析构函数

    2024-03-21 16:26:01       41 阅读
  3. FDU 2018 | 1. 求众数

    2024-03-21 16:26:01       46 阅读
  4. el-table原始列表转换成树形数据

    2024-03-21 16:26:01       37 阅读
  5. blender记一下法线烘焙

    2024-03-21 16:26:01       39 阅读
  6. 在springboot中利用Redis实现延迟队列

    2024-03-21 16:26:01       40 阅读
  7. 【linux】grep 命令

    2024-03-21 16:26:01       44 阅读
  8. 【AI】计算机视觉是什么

    2024-03-21 16:26:01       44 阅读