添加环境变量: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

Logo

瓜分20万奖金 获得内推名额 丰厚实物奖励 易参与易上手

更多推荐