I am in the process of implementing Gitlab at my workplace and transitioning everyone over to it for better code reviews, issue management directly linked to commits, and in
Instead of trying to checkout on a distant server, you should instead (in the same post-receive hook) push to that distant server.
Since Git 2.3.3 and 2.4.0, using a push-to-deploy, using the config receive.denyCurrentBranch = updateInstead
on the git server side.
Note that there are some caveats to this approach.
- Your server will contain a
.git
directory containing the entire history of your project. You probably want to make extra sure that it cannot be served to users!- During deploys, it will be possible for users momentarily to encounter the site in an inconsistent state, with some files at the old version and others at the new version, or even half-written files. If this is a problem for your project, push-to-deploy is probably not for you.
- If your project needs a "build" step, then you will have to set that up explicitly, perhaps via githooks.