bat操作git(一键提交)

添加环境变量:D:\Git\Git\cmd

环境变量添加完毕后就可以直接在命令框使用git命令了

脚本实现

实现一键完成远程仓库的更新

@echo off
git add . 
git commit -m "daily push data-structure-and-algorithms"
git push
echo push respostory successfully
pause

 如果需要传递参数(提交信息)

@echo off
git add . 
git commit -m "%1"//待传入的参数
git push
echo push respostory successfully
pause

 需在当前文件夹建立的命令框调用

定时任务

给windows设置定时任务来自动提交git

#设置两个定时的提交任务:12:00和18:00
schtasks /create /sc daily /tn gitpushalgorithms1 /tr D:\桌面\大学课程\数据结构和算法\gitpush.bat /st 12:00 /et 12:30 /k
schtasks /create /sc daily /tn gitpushalgorithms2 /tr D:\桌面\大学课程\数据结构和算法\gitpush.bat /st 18:00 /et 18:30 /k
#任务的查询和删除
SCHTASKS /Query /FO table |find "git"	#模糊查询
SCHTASKS /Query /FO table |find "gitpushalgorithms1"
SCHTASKS /Delete /tn "gitpushalgorithms1" /f

注意去掉脚本的pause命令,修改后的脚本

@echo off
git add . 
git commit -m "daily push data-structure-and-algorithms"
git push

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值