Git: auto pull from repository?

前端 未结 4 407
北海茫月
北海茫月 2020-11-30 01:31

Is there any way to set up git such that it listens for updates from a remote repo and will pull whenever something changes? The use case is I want to deploy a web app using

相关标签:
4条回答
  • 2020-11-30 01:55

    There are continuous integrations programs like Jenkins or Bamboo, which can detect commits and trigger operations like build, test, package and deploy. They do what you want, but they are heavy with dependencies, hard to configure and in the end they may use periodical check against git repository, which would have same effect like calling git pull by cron every minute.

    0 讨论(0)
  • 2020-11-30 02:04

    On unix-likes you can create cron job that calls "git pull" (every day or every week or whatever) on your machine. On windows you could use task scheduler or "AT" command to do the same thing.

    0 讨论(0)
  • 2020-11-30 02:13

    Git has "hooks", actions that can be executed after other actions. What you seem to be looking for is "post-receive hook". In the github admin, you can set up a post-receive url that will be hit (with a payload containing data about what was just pushed) everytime somebody pushes to your repo.

    For what it's worth, I don't think auto-pull is a good idea -- what if something wrong was pushed to your branch ? I'd use a tool like capistrano (or an equivalent) for such things.

    0 讨论(0)
  • 2020-11-30 02:17

    I know this question is a bit old, but you can use the windows log and git to autopull your project using a webhook and php (assuming your project involves a webserver. See my gist here : https://gist.github.com/upggr/a6d92e2808e9628ebe0d01fd93569f4a

    0 讨论(0)
提交回复
热议问题