Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Search and you'll find various software doing it. If you just want a minimal shell thing for repos themselves, you can fetch a list from GH API for user X and clone them into destination `/home/X/repos` like so:

  $ curl -s https://api.github.com/users/X/repos?per_page=100
    | jq -r 'map([.name,.clone_url]|@tsv)|.[]'
    | xargs -n2 sh -c '[[ -d $0.git ]] || git clone --mirror $1 /home/X/repos/$0.git'
Then you can just put a cronjob to sync them like

  $ find /home/X/repos -maxdepth 1 -mindepth 1 -exec sh -c 'cd {} && git remote update' \;
Replace /users/X with /orgs/Y for an org. Pagination for >100 repos is left as an exercise to the reader.

Note that this will create mirror (bare) repos, so if you want to checkout you can e.g. git clone file:///home/users/X/repos/foo.git somewhere else.

Bonus: If you want to have these mirrors available remotely and self-hosted, the official git book lays out your options pretty nicely: https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protoco...

Easiest are probably git protocol (handled by git itself) or "Dumb HTTP" (just server these directories from a static HTTP server)



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: