9

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?

Community
  • 1
  • 1
Wayne Weibel
  • 933
  • 1
  • 14
  • 22
  • 3
    Once you fork the public repo on your gitlab server, you have your own independent repo. It is a good idea to use a private fork as a reference repo for your team to update by merging their changes after commiting them to their local copies, but you must incorporate (by merging from time to time) any further changes introduced by commits on the public repo since the moment you fork, if you want them to be in your project. Check this for specific info on how to merge two remote repositories http://stackoverflow.com/questions/1767980/merging-two-remote-repositories-in-git – NotGaeL Jan 20 '15 at 21:10
  • I have the same question, but with an extra twist: the remote repo that I want to fork does not have http(s):// access, but only git:// access. Is it possible to fork in GitLab a remote repo which only has git:// access ? – Sorin Postelnicu Sep 16 '15 at 16:12

2 Answers2

2

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.

petrpulc
  • 940
  • 6
  • 22
0

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

JCS
  • 3
  • 4
Xin Meng
  • 1,982
  • 3
  • 20
  • 32