git 不同仓库 同步

这篇具有很好参考价值的文章主要介绍了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文章来源地址https://www.toymoban.com/news/detail-845732.html

到了这里,关于git 不同仓库 同步的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • GIT 不同仓库之间合并代码

    合并两个不同仓库的代码通常需要以下步骤。这里以合并两个远程仓库为例: 添加远程仓库: 在本地仓库中,使用以下命令添加第二个远程仓库: 例如: 确保你已经有权限访问这两个远程仓库。 拉取第二个仓库的代码: 使用以下命令拉取第二个远程仓库的代码: 例如:

    2024年04月16日
    浏览(35)
  • git从主仓库同步到fork仓库

    方式一:通过git命令 方式二:通过git页面 执行完该命令,本地项目将同时关联到私有仓库与远程仓库地址。 命令参数:upstream 表示远程仓库别名,类似于origin 方式一:idea fetch重新拉取最新地址 执行路径:项目右键 - Git -Repository - Fetch 方式二:更新主库命令方式 方式一:使

    2024年02月03日
    浏览(34)
  • git如何同步本地仓库与远程仓库代码

    fork仓库代码至本地后如何同步原仓库或其他成员仓库代码至本地 1、git remote查看远程仓库 目前只有origin是因为只是克隆了自己的仓库,还没有配置其他远程仓库,这是git给予克隆仓库的默认名 2、git remote add 别名 地址;手动添加需要同步的远程git仓库,同时指定一个简写

    2024年02月02日
    浏览(37)
  • git合并两个不同仓库的方法

    在日常的开发中我们经常会遇到一种情况,我们针对a地项目开发时建了仓库a,针对b地项目开发时建了仓库b,仓库ab之间有一定关联性,但是ab仓库又不是同源的仓库,如果要将a仓库和b仓库代码合并,常常会出现报错,那么如何将ab仓库合并呢?特地介绍如下 下面以a仓库作为

    2024年02月04日
    浏览(35)
  • Git同步一个仓库代码到另一个仓库

    在当前仓库操作,更新代码库 查看当前仓库origin只有一个,接下来我们要add另一个仓库的origin newOrigin远程仓库名称,可以随便起个方便记忆的,目的是在本地添加一个新的远程连接 newOrigin后面是newOrigin的一个分支,可以指定为master或你要push的目标分支,都可以。执行完命令

    2024年02月10日
    浏览(29)
  • 【git】github 如何同步别人的仓库

    假设你有两个 Git 仓库 ,并希望同步它们,以便它们含有相同的内容。 你必须要在 Git 中配置一个远程服务器指向上游的仓库地址,这样你在 fork 中的更改才能同步到原始的仓库里。这样也能把原始仓库中的变更同步到 fork 里。 打开终端,进入本地项目的工作目录。 查看你

    2024年02月10日
    浏览(30)
  • git 同步远程仓库远程分支至本地

    1、克隆远程仓库 2、查看分支 3、将本地分支与远程保持同步 4、新建本地分支,名称与远程仓库分支名称一致,并同步远程分支 5、同步所有远程分支 6、将本地所有分支与远程保持同步 7、最后拉取所有分支代码

    2024年02月15日
    浏览(41)
  • Git:不同仓库之间的cherry-pick

    一、操作步骤 添加远程仓库到本地 拉取该远程仓库的指定分支 运行cherry-pick命令 push到远程

    2024年02月13日
    浏览(35)
  • git本地新建分支,并同步到远程仓库

    1、新建本地分支 2、在远程仓库中新建分支,名称保持一致 3、查看本地分支 4、转到本地分支 5、删除本地分支 6、同步本地分支至远程仓库 7、如果有错误,提示版本不同步,如回退版本后修改了内容并需要同步,这时候可以使用强制推送

    2024年02月11日
    浏览(39)
  • git仓库与本地暂存区的同步问题

    向下同步 对于远程仓库的项目,初始化一个配置文件,配置远程仓库及相关信息,赋值远程仓库的地址,使用git pull命令即可拉取仓库代码。 git pull [remote_addr] 该部分完成向下同步 向上同步 向上同步时会遇到很多的问题,比较顺利的是add,commit,push没有障碍。 项目文件添加

    2024年02月14日
    浏览(34)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包