ekchom
ekchom

Reputation: 148

GitHub Mirror to Local Machine/Server

We use few projects (downloaded from github) from github. Since these project are mirrored from github as third_party project in cmake, clean build causes all the projects to be download again. We are behind proxy and downloading sometime takes 1-2 hrs (Traffic is contending with FB traffic and we can't control).

I have been thinking of setting up mirror server locally, and all the project download happens from that server. However I don't want to change the path in my local server ( ie https://github.com/google/grpc.git should be same as https://github-local-mirror.com/google/grpc.git ).

I understand I can configure local git repo and cloned from the local git repo and periodically updating local git repo from github, however path issue is very important.

Is there any way out here to maintain same path as github? Is there anything called local mirror service which allow github project to be mirrored locally ?

All question I have read so far talked about mirror on github, I want mirroring from github. So Please think before marking as duplicate.

Upvotes: 2

Views: 3382

Answers (1)

torek
torek

Reputation: 488193

Is there any way out here to maintain same path as github?

Yes: simply clone them on your mirror using the same path that they have on GitHub.

Is there anything called local mirror service which allow github project to be mirrored locally ?

No, but it's trivial. On your mirror machine, you will want to run:

git clone --mirror <github-URL>

such that each clone winds up available on the mirror at google/path when it was at path on GitHub. Having done that, you can simply run a git fetch --prune (or git remote update --prune) in each clone.

Given that there is going to be a small, finite list of mirrors you will maintain, you can simply have a (file containing a) list of paths on your mirror machine and use a cron job to run the updates, e.g.:

*/5 * * * *   for path in $(cat $HOME/mirrors); do (cd $path && git remote update -p); done

or similar.

Upvotes: 2

Related Questions