Is it possible to have gitlab setup to automatically sync (mirror) a repository hosted at another location?
At the moment, the easiest way I know of doing this involves manually pushing to the two (gitlab and the other) repository, but this is time consuming and error prone.
The greatest problem is that a mirror can resynchronize is two users concurrently push changes to the two different repositories. The best method I can come up with to prevent this issue is to ensure users can only push to one of the repositories.
I also created a project to mirror repositories in GitLab 6 through the API (API mostly used on project creation only).
https://github.com/sag47/gitlab-mirrors
You can use hooks to customize a script that runs after some commit. With that you can send the new changes to another repository. Look for more information about hook in the following page: http://git-scm.com/book/en/Customizing-Git-Git-Hooks
The best option today is to use GitLab CI. It is essentially an already implemented server for the webhooks, which automatically clones for you and let's you run arbitrary shell commands: all you have to do then is to push.
services are a the best option if someone implements them: they live in the source tree, would do a single push, and require no extra deployment overhead.
The key implementation difficulty now is how to store the push credentials safely: likely the best option for GitHub is to get a key somehow (Oauth on UI through the service would be perfect) and store that plaintext.
Another option which has just been added are custom hooks.
GitLab Enterprise Edition now supports repository mirroring as of version 8.2. Information about how to configure this is in the Repository Mirroring help topic.
Update Dec 2016: Mirroring is suported with GitLAb EE 8.2+: see "Repository mirroring".
As commented by Xiaodong Qi:
Original answer (January 2013)
If your remote mirror repo is a bare repo, then you can add a post-receive hook to your gitlab-managed repo, and push to your remote repo in it.
As Gitolite (used by Gitlab) mentions:
which would be in:
Caveat (Update Ocotober 2014)
Ciro Santilli points out in the comments:
See (and vote for) feeadback "Automatic push to remote mirror repo after push to GitLab Repo".
Update July 2016: I see this kind of feature added for GitLab EE (Enterprise Edition): MR 249
Note that the recent
Remote Mirror Repository
(issues 17940) can be tricky:Here is one of the repos this fails with: https://gitlab.com/pushrocks/npmts Edited 2 months ago
If not hosting your own GitLab, it's worth knowing GitLab.com has introduced this feature directly, without any workarounds.
https://yourgithubusername:yourgithubpassword@github.com/agaric/guts_discuss_resource.git
Note that if you are pulling from a remote repository, it will still push on to the remote repository set here. I haven't tried it, but you should be able to push to and pull from the same repository.