Wayne Weibel
Wayne Weibel

Reputation: 973

GitLab fork remote public repo

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?

Upvotes: 9

Views: 12741

Answers (2)

Xin Meng
Xin Meng

Reputation: 2100

Maybe you can try the GitLab mirroring feature. It supports pulling from the remote repo.

Upvotes: 0

petrpulc
petrpulc

Reputation: 970

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.

Upvotes: 2

Related Questions