How to mirror private Github repositories to Gitea

2 min. read

In case of some outages or a locked account I would not be able to access any Github repositories again. Like with everything else, backups are also important for your code. As I own a Synology Diskstation that already holds a lot of backups, that was the best place to set up some mirrors of all my Github repositories. I installed Gitea, a small and fast alternative to Gitlab as a Docker image on my Diskstation and was ready to go just a little later.

Errors while mirroring private Github repositories

While all public repositories got mirror without any issues, the first errors popped up while trying to mirror a private repository:

Error while mirroring in Gitea

While doing a migration, Gitea asks for the repo URl and you can specify authentication for that repo if needed. I thought that the “Clone Authorization” setting would allow me to pass my username and API token. After searching for the error and possible solutions I couldn’t find anything that helped me. So I tried a few things on my own.

Successfully mirror private repositories

For whatever reason, Github does not accept the format used by Gitea if you pass your credentials via the “Clone Authorization” setting. But as we mirror with a basic HTTPS URL we are able to pass basic HTTP authorization information directly in the URL.



With that in mind we can now easily setup Gitea to mirror private Github repositories, while leaving the Clone Authorization empty:

Successful Gitea setup for mirroring

And voila:

Successful Gitea mirror screenshot

Using this configuration we can easily mirror, or migrate, any private Github repository.


0 Mentions