Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: auto pull from repository?

Tags:

git

deployment

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 git (so I get version control of the deployed application) but want to put the "central" git repo on Github rather than on the web server (Github's interface is just soooo nice).

Has anyone gotten this working? How does Heroku do it? My Google-fu is failing to give me any relevant results.

like image 716
Li Haoyi Avatar asked Apr 02 '12 14:04

Li Haoyi


People also ask

What is auto pull?

The Auto Pull Configuration function allows you to restore required settings to your devices automatically and apply new settings globally using a settings file saved in a shared network folder.

Does git pull pull from remote?

The git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content. Merging remote upstream changes into your local repository is a common task in Git-based collaboration work flows.


2 Answers

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.

like image 97
ksol Avatar answered Oct 02 '22 01:10

ksol


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.

like image 31
SigTerm Avatar answered Oct 02 '22 02:10

SigTerm