GitLab fork remote public repo

11,749

Fork is nothing but a new repository with added remote

There are three main ideas that need to be understood:

  • each Git repository is a standalone repository
  • "fork" is a fancy word for repository with remote pointing to original repository
  • GitLab is nothing more than a user interface to a real Git repository on a filesystem

Therefore, if you insist that some branch(es) should be kept up to date on your server with the branches on remote (git:// or http(s)://) you can add new remote to your real git repository (usually located at /home/git/repositories, check your gitlab.yml) and set-up a cron to pull changes from such remote.

BUT, a lot of things may go wrong if the pull won't be a fast-forward and merge would be needed.

A solution to that would be to fetch the remote and reset instead, but this time all your changes would be lost.

Better do it all by hand

If only possible, a much better solution would be to dedicate a bit of time and pull the changes by hand, check for consistencies and push to your local copy.

Share:
11,749
Wayne Weibel
Author by

Wayne Weibel

BS in Computer Science and MA in HCI (Human Computer Interaction) from SUNY Oswego. I have worked for several years developing web based applications and interfaces: Java, PHP+MySQL, Ruby, Python, Drupal, CoffeeScript, jQuery, AJAX, XML/XSLT

Updated on July 27, 2022

Comments

  • Wayne Weibel
    Wayne Weibel almost 2 years

    My organization has a dedicated machine for our GitLab install. I regularly work with other public projects (Drupal.org and Github). I would like to have a repo on our GitLab with a branch that would track the remote Drupal or Github project, in addition to having our own development and production branches.

    Want this to be on the GitLab server (machine) so a developer is not responsible for tracking and updating from the public remote.

    Essentially, fork public repo tracked on 'master', with internal branches 'devel' and 'prod'; developers only cloning internal devel branch. Then have the ability to pull from remote to master, then merge to other internal branches as desired. Can that be accomplished via the web interface or with hooks? or ...

    Following the answer to Create a fork of public git repo for github it would seem that it would need to be a script to pull from public remote to local, then push to GitLab master, with the script set as a cron job. Yeah?