win 下 git 提交代码脚本

2021年3月再次升级一下 ,提交代码必须输入提示信息,校验每条git 命令执行情况,有异常退出执行

#!/bin/bash
if [ ! -n "$1" ]; then
  echo "请输入提交信息"
  exit
else
  msg="$1"
fi

echo $msg

function echoMsg() {
  echo -e "\n$1:"
  checkCommand "$1"
}

function checkCommand() {
    if ! $1; then echo -e "\n$1: failed !!!"; exit 1; fi
}

echoMsg "git pull"
echoMsg "git status"
echoMsg "git checkout V3-014-dev"
echoMsg "git pull"
echoMsg "git add application/"
echoMsg "git status"
echoMsg "git commit -m $msg"
echoMsg "git push origin V3-014-dev"
echoMsg "git checkout develop"
echoMsg "git pull"
echoMsg "git merge origin V3-014-dev"
echoMsg "git push origin develop"
echoMsg "git status"

 

2021年 升级一下 

可以看到每条执行的命令:

#!/bin/bash
if [ ! -n "$1" ]; then
  echo "请输入提交信息"
  exit
else
  msg="$1"
fi

echo $msg

function echoMsg() {
  echo -e "\n$1:"
}
echoMsg "git pull"
git pull
echoMsg "git status"
git status

echoMsg "git checkout V3-009-dev"
git checkout V3-009-dev

echoMsg "git pull"
git pull

echoMsg "git status"
git status

echoMsg "git add application/"
git add application/

echoMsg "git commit -m $msg"
git commit -m "$msg"

echoMsg "git push origin V3-009-dev"
git push origin V3-009-dev

echoMsg "git checkout develop"
git checkout develop

echoMsg "git pull"
git pull

echoMsg "git merge origin V3-009-dev"
git merge origin V3-009-dev

echoMsg "git push origin develop"
git push origin develop

echoMsg "git status"
git status

 

执行结果如图:

 


2016年记录

每次提交代码敲好多命令有些麻烦,于是整理了下,写了个脚本

在项目根目录 写 push.sh 文件 

 

文件内容:

 

if [ ! -n "$1" ]; 
then
    msg="msg"
else
    msg="$1"
fi

git add application/  
git commit -m '$msg'  
git push origin lxl  
git checkout master
git pull  
git checkout lxl  
git merge origin master 
git checkout master
git merge origin lxl  
git push origin master
git checkout lxl  
git push origin lxl  
git status 

 

调用方法:

./push.sh 提交注释

 

如果 push.sh文件放在项目上层则,则调用方法为 

../push.sh

 

注:

msg为提交注释信息, lxl 为你自己的分支,master为主分支 ;

要注意msg 变量赋值的时候两边不要有空格;

git 命令如果要写在一行的话 可以用&&连接 ;

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值