Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GitLab fork remote public repo

Tags:

git

github

gitlab

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?

like image 832
Wayne Weibel Avatar asked Jan 20 '15 20:01

Wayne Weibel


People also ask

Can you fork a public repository?

Any public Git repository can be forked or cloned. A fork creates a completely independent copy of Git repository. In contrast to a fork, a Git clone creates a linked copy that will continue to synchronize with the target repository.

Can you fork a GitLab repo to GitHub?

If you need to fork a GitHub or GitLab repo, it's as simple as navigating to the landing page of the repository in your web browser and clicking on the Fork button on the repository's home page. A forked copy of that Git repository will be added to your personal GitHub or GitLab repo. That's it.

How do I fork a repository to my GitLab account?

You can fork a project in GitLab by going to the project and clicking on the Fork button. This will create a copy of the project in your own namespace. You're allowed to do whatever you want with this copy as it's is your own.


1 Answers

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.

like image 81
petrpulc Avatar answered Sep 21 '22 04:09

petrpulc