Git- Automatic pull on production server?

ian profile image Ian ・1 min read


I'm hosting my own Gitea server on which I have most of my web projects stored.

After pushing changes to a repo, I always have to connect to my shared hosting server on which I cloned the repo and run "git pull".

I know I could setup a cronjob to run this command every few minutes, but is there a better solution, which would allow an instant deployment?



markdown guide

You could use the webhooks and with a couple of scripts make the work, this is the simplest solution.

Another way is use Drone or gocd that kind of tools(continuous delivery/integration) use webhooks too.


Can you push to the server instead? Pushing to a bare repo that only contains a hook to checkout the latest commit to the served directory is a standard way of working (or it used to be...)

You might not be able to do that, depending on your hosting, though.


Well, that would be possible, but for convenience I'd like to use my Gitea server, since it also offers a nice UI.

Client ---> Gitea ----> Server


Isn't there a simpler solution? I read something about git hooks


Sure. You'd just need to create a script like a bash or python script, etc. But that probably puts you back in the using CRON job to run it I'd think.

If you're using an app that exposes a way to fire the script or actual book if available then that would be ideal, but my guess is you would have explored that if you had that option.