There is a test repository, on the server it lies in the directory:

 /git-data/repositories/root/test.git 

The working site itself is located on the same server, but lies in the /sites/test/ directory.

How to upload all changes from the master branch (or some other, for example qa-release-1.0 ) repository to the working folder of the site (or for the qa-release-1.0 branch there will be another site folder where the test copy of the site is located)?

In other words, how to deploy the master repository branches to the test directory /sites/test/ , and the qa-release-1.0 branches to the /sites/test-qa/ directory? (all on the same machine)

  • About Builds from gitlab is better to create a separate question. - edem
  • 1. What does “upload changes” mean? 2. You write about the directory on the server and write about gitlab. decide what access you need to this repository. 3. What does a website have to do with the repository? // please try, before sending a question, to assess whether it will be clear what is stated in it to anyone other than you. - aleksandr barakin
  • @alexanderbarakin, edited, I have removed the question about gitlab, I want to understand what is now ... - sanu0074
  • one
    @ sanu0074, supplemented the answer with the second version. - aleksandr barakin

1 answer 1

not knowing exactly what you mean by the terms “unload all changes from a branch” and “make a deployment branches”, I dare to suggest that you just want to clone the repository into a specific directory and switch to a specific branch.

This can be done with one command (clone and switch):

 $ git clone -b ветка url_репозитория каталог 

for example:

 $ git clone -b master /git-data/repositories/root/test.git /sites/test/ $ git clone -b qa-release-1.0 /git-data/repositories/root/test.git /sites/test-qa/ 

details are in man git-clone .


if the LazyBadger guess is correct, use the archive command:

 $ git archive --remote=url-репозитория ветка > /путь/к/архиву.tar 

for example (immediately with unpacking, without creating an intermediate file):

 $ git archive --remote=/git-data/repositories/root/test.git master | tar -x -C /sites/test/ $ git archive --remote=/git-data/repositories/root/test.git qa-release-1.0 | tar -x -C /sites/test-qa/ 

details are in man git-archive .

  • Thanks, @LazyBadger was right in his conjectures. And about gitlab, I meant, is it possible somehow to execute archive commands from the gitlab interface with unpacking, without creating an intermediate file? not to go to the server. Therefore, I asked about builds, for what this item on the menu ... - sanu0074
  • one
    @ sanu0074, the url repository can be any understandable git . including the one that provides gitlab, github, etc. - aleksandr barakin