自动化脚本同步单个平台所有小程序(本质跨平台uniapp但是业务紧急,按需使用)

点击查看代码
#!/bin/bash

# 设置你要cherry-pick的commit hash
commit_hash="a5bdefa5d8cccc7cb73b85a84355c6d977a918fb"

# 获取所有本地分支的名字,排除远程跟踪分支
branches=$(git branch --format '%(refname:short)')

# 遍历每一个分支并执行git cherry-pick
for branch in $branches; do
    echo "Checking out and cherry-picking into branch: $branch"
    # 切换到目标分支
    git checkout $branch
    # 执行cherry-pick
    git cherry-pick $commit_hash
    # 检查上一步是否成功,如果失败则打印错误信息并继续处理其他分支
    if [ $? -ne 0 ]; then
        echo "Error occurred while cherry-picking into $branch. Fix conflicts and commit to continue."
    else
        echo "Successfully cherry-picked into $branch."
    fi
done

echo "All local branches processed."
posted @ 2024-06-18 15:45  jialiangzai  阅读(31)  评论(0)    收藏  举报