美文网首页
Git 一键部署 自动上传git批处理bat

Git 一键部署 自动上传git批处理bat

作者: 辣辣不乖 | 来源:发表于2020-12-21 20:35 被阅读0次

    新建txt文本文件扩展名改FilePush.bat,打开记事本编辑如下:

    @echo off
    rem 设置默认值
    set content= 常规提交
    set /p content= 输入本次提交的内容,不建议省略:
    
    git add .
    
    rem 提交更新
    git commit -m %content%
    
    rem 推送到服务端
    git push
    
    pause
    

    @echo off #屏幕不显示bat文件中所有的命令行

    echo "-------Begin-------" #输出字符,"-------Begin-------"

    set /p msg=请输入提交注释: #接受输入的内容,以回车表示结束,赋值给变量 msg

    echo 推送成功:【%msg%】 #输出字符,推送成功:【%msg%】,msg为输入的变量值

    echo "--------End!--------" #输出字符,"--------End!--------"

    pause #暂停,否则 dos 界面会一闪而过

    @echo off
    echo "-------Begin-------"
    git status
    set /p msg=请输入提交注释:
    git add .
    git commit -m %msg%
    git pull
    git push
    echo 推送成功:【%msg%】
    echo "--------End!--------"
    pause
    

    git commit 信息可以自定义,%date%是日期,%time%是时间,MSDOS下的方式

    git add *
    git commit -m "%date% %time%: Updated By Edwin Xu"
    git push origin master
    exit
    

    其他环境可改扩展名为 FilePush.sh 以上命令前加 set -e 命令失败停止部署
    If a command fails then the deploy stops
    set -e

    相关文章

      网友评论

          本文标题:Git 一键部署 自动上传git批处理bat

          本文链接:https://www.haomeiwen.com/subject/acqenktx.html