0

How do I mirror one gitlab repository with the another.

I have a repository which should be in sync with the protected branches of another repository.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
Ajay Kumar
  • 29
  • 4
  • Mirroring from GitLab to GitHub over SSH connection is explained [here](https://stackoverflow.com/a/73728220/3586084). – alierdogan7 Sep 15 '22 at 08:56

2 Answers2

0

I solved this by writing a Gitlab server hook like the following for ALL REPOSITORIES (look at the posted official guide link):

#!/bin/sh

# https://docs.gitlab.com/ee/administration/server_hooks.html#create-a-server-hook-for-a-repository

# Encode path slashes with dots.

FIXED_PROJECT_PATH=$(echo ${GL_PROJECT_PATH} | sed -r 's:/:\.:g')

# Mirror the repository, even if does not yet exist.

PROJECT_URI=<<GITLAB_MIRROR_URL>>/${FIXED_PROJECT_PATH}.git

git push --mirror ${PROJECT_URI}
exit 0 # Force successfully execution

NB: remember to subsitute <<GITLAB_MIRROR_URL>> with your own.

Antonio Petricca
  • 8,891
  • 5
  • 36
  • 74
0

You can use GitLab mirroring capability to achieve that, it's built-in the platform.

ozeebee
  • 1,878
  • 2
  • 23
  • 26