简体   繁体   中英

Deploys using central Git repository

I have created a central bare Git repository managed by GitLab for our developers to push changes to. I have subsequently pushed a "test" branch to this central repository. Now I need to pull or export from this repository to a local filesystem to serve the "test" site files. I'd use the same flow for merging changes into staging and production branches.

What's the best practice way to set up my web server to pull the test branch (and only the test branch?) code down from the central repository to the local file system? Do I clone the repository? Do a git init then git pull URL ? Is there any way to force this local file system to only ever update from the test branch or is that not good/standard practice?

Is it bad practice to serve files in a Git repository and should I be exporting instead?

One solution would be to define a gitlab webhook , which would send a JSON message to your web server with the relevant information (ie commits and branch which were just pushed).

Your web server, listening to those JSON messages, would then:

  • go to the right repo (I would recommend 3 separate non-bare repo for your web server to monitor, each one with a different url, instead of trying to do everything in just one repo)
  • git fetch , and merge the right origin/branch to branch (like origin/test to test ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM