[shell] git并发提交

rm -rf project1
git clone http://yourname:token@gitlab.your.com/group1/project1.git --depth 1
cd project1

i=1
while true
do
    sed -i "s/$old_tag/$new_tag/" app_file
    git add app_file
    git config user.name yourname
    git config user.email yourname@email.com
    git commit -m "$new_tag"
    git push
    if [ $? -eq 0 ];then
        echo "推送成功。"
        exit 0
    else
        if [ $i -gt 3 ];then
            echo "失败次数过多,请排查原因。"
            exit 1
        fi
        echo "第$i推送失败,等待重新尝试。"
        git reset --hard HEAD^
        git pull
    fi
    ((i++))
    sleep $(($RANDOM % 10 + 10))
done

  

 

posted @ 2023-04-12 09:32  金枪语  阅读(37)  评论(0编辑  收藏  举报