mirror of
https://github.com/142vip/408CSFamily.git
synced 2026-05-16 14:04:17 +08:00
feat(scripts): 新增sync脚本,同步master分支到不同仓库
This commit is contained in:
36
scripts/sync
Executable file
36
scripts/sync
Executable file
@@ -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
|
||||||
Reference in New Issue
Block a user