Sync GitLab repo with remote server

Sync remote server with GitLab repo, everytime a new commit is pushed.

I am using the free plan of GitLab.com and this is the problem I am trying to solve:

  1. I have my desktop where I work on my project, and commit changes from it to GitLab
  2. I have a remote server, which needs to keep an up to date copy of the repo, which I end up doing manually, using git clone / git pull.
  3. I never edit my source directly on the remote server.
  4. The remote server is not always publicly acessible. Some times it is a VPS on DigitalOcean, and sometimes it is just a Raspberry Pi on my home network, behind a NAT.

Is there a way to setup a small service on my “remote” server, that looks out for a new commit being pushed to my GitLab repo, and automatically pull it?
Thanks in advance!

Hi,

You can do it in Gitlab. Go to your Project → Settings → Repository → Mirroring Branches.

Here you put the URL you wish to push to (including the username/password, or even better, username/access-token). So for example:

https://username:password@mygitserver.domain.com

or:

https://username:access-token@mygitserver.domain.com

of course you will need to set up the project on the Git server that you are pushing to. As soon as you commit to your gitlab.com repo, it will automatically push to the other server.

See the docs: Repository mirroring | GitLab

Can you explain the bit about “the Git server that you are pushing to”? I don’t have a git server, and I was wondering if there is a small system daemon that I can run, that checks if there are any new commits to the original GitLab repo and pull those changes?
I don’t intend on installing something like GitLab on my mirroring end-point.

I have my desktop where I work on my project, and commit changes from it to GitLab
I have a remote server, need to clone a copy of the repo using git clone on remote server. How can we achieve this