Using 'git checkout -f' to deploy files from a bare git repo in Gitlab

后端 未结 1 546
后悔当初
后悔当初 2020-12-20 08:01

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

相关标签:
1条回答
  • 2020-12-20 09:00

    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.
    0 讨论(0)
提交回复
热议问题