定时提交代码到gitlab

定时提交代码

用于同步笔记到GitLab, 不适合用于生产环境代码.

Windows

  1. 打开任务计划程序.
  2. 右方点击创建基本任务.
  3. 输入任务名称, 运行时间.
  4. 选择执行启动程序, 在某个位置新建脚本文件schedule.bat, 输入如下

    1
    2
    3
    4
    5
    6
    e:
    cd E:\GitLab\note
    git status
    git add .
    git commit -m "auto update"
    git push origin master
  5. 其它默认, 点击完成, 左边点击 任务计划程序库 , 右键刚刚创建的任务, 点击运行.

注: 若用https连接, 则要走在.config中设置密码

1
2
[remote "origin"]
url = git@github.com:USERNAME/REPONAME.git

Linux

采用Crontab定时任务

新建执行脚本文件schedule.sh

1
2
3
4
5
cd gitlab/note
git status
git add .
git commit -m "auto update"
git push origin master

每天3点钟运行

1
0 3 * * * bash schedule.sh