git自动提交脚本

匿名 (未验证) 提交于 2019-12-03 00:14:01

每次在linux都要重新一遍一遍敲着这些重复的代码,我想着能够优化一下,做个一键脚本,减少重复劳动。

#!/bin/bash git status   read -r -p "是否继续提交? [Y/n] " input   case $input in     [yY][eE][sS]|[yY])         echo "继续提交"         git add -A         git commit -m $1         git push origin $2                     exit 1         ;;      [nN][oO]|[nN])         echo "中断提交"         exit 1             ;;      *)     echo "输入错误,请重新输入"     ;; esac         

循环提交脚本

#!/bin/bash git status   while true; do     read -r -p "是否继续提交? [Y/n] " input       case $input in         [yY][eE][sS]|[yY])             echo "继续提交"             git add -A             git commit -m $1             git push origin $2                         exit 1             ;;           [nN][oO]|[nN])             echo "中断提交"             exit 1                    ;;           *)         echo "输入错误,请重新输入"         ;;     esac done

操作跟单次提交一样

有时候,我们本地开发提交代码用svn,提交到代码仓库,然后代码仓库推送到目标服务器

#!/bin/bash cd 代码路径 svn up version=`svnversion |sed 's/^.*://' |sed 's/[A-Z]*$//'` #version=`svn info|grep "Last Changed Rev"` branch=仓库地址  git status   read -r -p "是否继续提交? [Y/n] " input   case $input in     [yY][eE][sS]|[yY])         echo "继续提交"         git add .         git commit -m $version         git push $branch master         ;;       [nN][oO]|[nN])         echo "中断提交"         exit 1                ;;       *)     echo "输入错误"     exit 1     ;; esac

执行的时候直接./gitbash.sh 就好了,因为提交信息跟仓库地址我是直接写死的

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!