Migrate existing repositories on a Gogs instance.
Gogs is a lightweight self-hosted Git service. There's a neat GitHub-like interface to show, the repositories, and I find it perfect to mirror public GitHub repositories on a home server, and have really private repositories (that don't even leave your home, unlike "private" cloudish solutions). It's also really lightweight, unlike GitLab, and can easily run with SQLite on tiny computers like a Raspberry PI!
There is a built-in way to migrate external repositories, with a mirror option so your local copy is always up-to-date. And the interesting thing is there's an API to automate this task.
gogs-migrate is a script to automatically migrate (and optionally mirror) all your repositories from different sources (currently only GitHub public repositories are supported), to your Gogs instance.
You need to configure your Gogs URL (
--gogs), access token and UID
--gogs-uid). If those options are not passed via
CLI, and a configuration file is given (
gogs-migrate will try to read them from the configuration file.
Otherwise, it will prompt for the missing options.
Then, you can configure a source for the repositories to migrate.
Currently, only GitHub is supported, with the
--github-user option. It
will find only the public repositories, and there's currently no way to
configure credentials to access private repositories. You can migrate
your forks with the
--with-forks option, but by default gogs-migrate
will ignore them.
On Gogs side, you can pass
--mirror so the migrated repositories are
flagged as mirrors (Gogs will update them periodically), and
to make them private.
npm install -g gogs-migrate
Clone this repository, then in the directory:
You can now use
bin/gogs-migrate (or put
$PWD/bin in your
||Read options from given YAML configuration file.|
||Gogs URL prefix (like
||Gogs access token (required, prompt otherwise).|
||Gogs UID (required, prompt otherwise).|
||GitHub API prefix (defaults to
||GitHub username to stream repositories from.|
||GitHub user token to access private repositories.|
||Create mirror repositories.|
||Force private repositories (copy source visibility otherwise).|
||Include forked repositories.|
||Save migrated repositories to configuration file to avoid downloading them again the next time.|
You can specify a YAML configuration file with the
It can contain all the normal CLI long options, with the leading
gogs: https://git.example.com gogs-token: foo gogs-uid: 42 github-user: bar mirror: true
gogs-pass is not specified, and if it's not given via CLI, so
you will be prompted for your password (that's the recommended way).