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 命令如果要写在一行的话 可以用&&连接 ;