11

In a local gitlab I created a copy of project nova (https://github.com/openstack/nova).

How do I keep the local nova repo in sync with github, updating maybe once per hour or per day?

I would like a solution similar to what is described here for bitnami: http://wiki.bitnami.com/Applications/BitNami_GitLab#Keeping_in_sync_with_the_GitLab_repository_at_GitHub

(I used Devstack to install Openstack.)

6

GitLab now has this feature built-in!
Since GitLab EE 8.2 it's supported. Hooray!

Pulling from a remote respository

You can set up a repository to automatically have its branches, tags, and commits updated from an upstream repository.
...

When creating a new project, you can enable repository mirroring when you choose to import the repository from "Any repo by URL". Enter the full URL of the Git repository to pull from and click on the Mirror repository checkbox.

GitLab auto mirroring

For an existing project, you can set up mirror pulling by visiting your project's Settings ➔ Repository and searching for the "Pull from a remote repository" section. Check the "Mirror repository" box and hit Save changes at the bottom.
...

  • 1
    Their example uses gitlab, I followed it exactly except replaced that part with Github, and the updating thing never finishes... – MarcusJ Jul 13 '17 at 20:36
  • @MarcusJ Exactly the same here, did you find a solution? – MemphiZ Nov 2 '18 at 11:25
  • It's been a while since I had to do this, but I think what I did was use the ssh url in the format of ssh://git@gitlab.com:UserName:RepoName.git – MarcusJ Nov 2 '18 at 21:49
  • I just made this work, pulling from github to gitlab is easy if your repo is public, just paste this URL in gitlab settings: https://github.com/yourGithubUserName/repoName.git, then choose the Password method in the combobox and leave the password textbox blank – knocte Jun 5 at 11:32
4

If you never need local commits, the following recipe will work:

Clone the repo with --mirror:

git clone --mirror https://github.com/openstack/nova.git

Then in a cronjob, you do this for an hourly update:

0 * * * * cd /path/to/nova.git && git fetch

The --mirror sets up the refspecs in such a way that subsequent fetches will update all local refs, so you don't need to merge the changes in. Of course that does mean that commits pushed to that repo are lost.

  • This doesn't seem like it answers the question, which is to get a mirror in GitLab. – Ken Williams May 3 at 15:43
3

I wrote a project with the intention of adding remote mirrors to GitLab. You can check it out here...

https://github.com/sag47/gitlab-mirrors

0

Create a cron job to update the repo

  • How to setting in gitlab? – user186107 Aug 20 '13 at 2:18
  • 2
    Update your question with the details you require, what you've tried, and what the exact problem is. – Drew Khoury Aug 20 '13 at 5:05
0

You can do this using cron jobs.

In your terminal type crontab -e (to edit your crontab) and add a new line at the bottom with the following.

* 0 * * * git clone ssh://username@hostname:port/repo

It will run a clone every day at midnight.

  • I hope it is Incremental updates. no need download all again. – user186107 Aug 20 '13 at 2:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.