Git 和 crontab
Git and crontab
如何使用 crontab 运行 git pull
命令?当我从目录手动 运行 它工作时,但是当我将命令添加为 crontab
作业时它不起作用。
crontab 文件中的命令如下所示:
* * * * * cd /path/to/repo/.git && git pull
我不会从这台机器推送任何东西,只需要一个本地副本与主存储库同步。
我得到的错误是:
fatal: This operation must be run in a work tree
这会起作用:
* * * * * cd /path/to/repo/ && git pull
您不需要进入 .git
文件夹。
我不建议使用 crontab 拉动,因为它可能非常低效,而且 git 每 1 分钟拉动一次,您可能会 运行 遇到很多问题。
看看这个脚本,它可能对你有帮助:
https://github.com/olipo186/Git-Auto-Deploy
这种拉取只会在每次推送时触发。
如果您仍然希望使用 crontab,请尝试 - 它应该像这样工作:
* * * * * cd /path/to/repo && git pull
谢谢,
亚当
做
* * * * * git -C /path/to/repo pull
-C <path>
Run as if git was started in <path>
instead of the current working directory.
如何使用 crontab 运行 git pull
命令?当我从目录手动 运行 它工作时,但是当我将命令添加为 crontab
作业时它不起作用。
crontab 文件中的命令如下所示:
* * * * * cd /path/to/repo/.git && git pull
我不会从这台机器推送任何东西,只需要一个本地副本与主存储库同步。
我得到的错误是:
fatal: This operation must be run in a work tree
这会起作用:
* * * * * cd /path/to/repo/ && git pull
您不需要进入 .git
文件夹。
我不建议使用 crontab 拉动,因为它可能非常低效,而且 git 每 1 分钟拉动一次,您可能会 运行 遇到很多问题。
看看这个脚本,它可能对你有帮助:
https://github.com/olipo186/Git-Auto-Deploy
这种拉取只会在每次推送时触发。
如果您仍然希望使用 crontab,请尝试 - 它应该像这样工作:
* * * * * cd /path/to/repo && git pull
谢谢,
亚当
做
* * * * * git -C /path/to/repo pull
-C <path>
Run as if git was started in<path>
instead of the current working directory.