From 9a0c018ebd8b772ca65763dc6969588d20cdfce4 Mon Sep 17 00:00:00 2001 From: "142vip.cn" Date: Thu, 16 Nov 2023 11:29:31 +0800 Subject: [PATCH] =?UTF-8?q?feat(scripts):=20=E6=96=B0=E5=A2=9Esync?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=EF=BC=8C=E5=90=8C=E6=AD=A5master=E5=88=86?= =?UTF-8?q?=E6=94=AF=E5=88=B0=E4=B8=8D=E5=90=8C=E4=BB=93=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/sync | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 scripts/sync diff --git a/scripts/sync b/scripts/sync new file mode 100755 index 0000000..c5c9009 --- /dev/null +++ b/scripts/sync @@ -0,0 +1,36 @@ +#!/bin/bash + +## +## 同步分支脚本 +## 使用: ./scripts/sync +## + + +# 远程仓库名称 +remoteList=("origin" "mmdapl" "chufan443" "lir0115") +# 获取当前分支名称 +current_branch=$(git rev-parse --abbrev-ref HEAD) + + +# master分支同步 +if [ "$current_branch" = "master" ]; then + + # 合并next分支内容到master分之 + git merge origin/next + + # 推送到每个远程仓库 + for repoName in "${remoteList[@]}" + do + echo "-->Pushing to $repoName in master branch..." + git push "$repoName" master + done +# next分支同步 +elif [ "$current_branch" = "next" ]; then + for repoName in "${remoteList[@]}" + do + echo "-->Pushing to $repoName in next branch..." + git push "$repoName" next + done +else + echo "当前分支是:$current_branch ,只允许在master和next分支上操作,并推送到远程!!!" +fi \ No newline at end of file