zoukankan      html  css  js  c++  java
  • git linux服务器拉取代码sh脚本,批量拉取git代码

    用于项目上线 或者 最新git代码拉取

    pull.sh

    echo "loading..."
    
    cd /www/blog
    
    #没有提交的修改暂存到stash里面
    git stash
    
    curr_branch=$(git symbolic-ref --short -q HEAD)
    pull_branch="master"
    
    if [ ${curr_branch} != ${pull_branch} ]; then
       git checkout ${pull_branch} 
    fi
    
    git pull
    
    #php /www/blog/init --env=prod --overwrite=all

    批量拉取代码

    push-all.sh

    #!/bin/bash
    
    # 确保脚本抛出遇到的错误
    set -e
    echo 项目路径:$1
    current_branch=$(git symbolic-ref --short -q HEAD) ##获取当前分支名
    echo 当前分支: $current_branch
    
    if [ -n "$(git status -s)" ]; then
      echo 有文件变更,请先处理,再执行
      read -p "按任意键关闭" -n 1
      exit 1
    fi
    
    #没有提交的修改暂存到stash里面
    #git stash
    
    projectArr=("main" "test2")
    
    for project in ${projectArr[@]}; do
      if git branch | grep ${project}; then
        echo
        echo "......................切换并拉取本地分支 $project ...................."
        newest_branch=$(git symbolic-ref --short -q HEAD)
        if [ ${newest_branch} != ${project} ]; then
          git checkout $project
        fi
        git pull
        echo "........................操作完成....................................."
        echo
      else
        if git branch -rv | grep ${project}; then
          echo
          echo "......................切换并拉取远程分支 $project ...................."
          git checkout -b ${project} origin/${project}
          echo "........................操作完成....................................."
          echo
        else
          echo $project分支不存在
          read -p "按任意键关闭" -n 1
          exit 1
        fi
      fi
    done
    
    read -p "按任意键关闭" -n 1
  • 相关阅读:
    HTML语言基础
    过滤器Filter
    新闻实现分页显示
    [转]Jmeter使用入门
    [转]ZK工作原理
    [转]UT-IT-ST-BBIT-SDV-SIT-SVT
    Unix编码哲学
    火星坐标、百度坐标、WGS-84坐标相互转换及墨卡托投影坐标转经纬度JavaScript版
    递归公用表表达式概述
    java写word转pdf
  • 原文地址:https://www.cnblogs.com/-mrl/p/13846118.html
Copyright © 2011-2022 走看看