This project periodically mirrors all GitHub repositories you have access to, pushing them to GitLab. It automatically creates any missing GitLab repositories and mirrors all branches, tags, and commits.
- Fetches list of all GitHub repositories (public and private)
- Automatically creates missing GitLab repositories
- Performs full
git push --mirror
to GitLab - Runs on a schedule using cron (default: every hour)
- Fully containerized via Docker
- Docker + Docker Compose
- GitHub token with access to your repositories (
repo
andread:org
scope) - GitLab token with permissions to create and push repositories (
api
scope)
Set these environment variables in docker-compose.yml
:
Variable | Description |
---|---|
GITHUB_TOKEN |
Personal GitHub token |
GITLAB_TOKEN |
Personal GitLab token |
GITLAB_NAMESPACE |
GitLab username or group where to mirror repos |
version: '3.8'
services:
github-gitlab-mirror:
image: ghcr.io/iu2frl/github-to-gitlab:latest
container_name: github-gitlab-mirror
environment:
GITHUB_TOKEN: ghp_xxx # Sostituisci con il tuo token GitHub
GITLAB_TOKEN: glpat_xxx # Sostituisci con il tuo token GitLab
GITLAB_NAMESPACE: tuo_username_o_gruppo
tmpfs:
- /root/repos
#volumes:
#- mirror-data:/root/repos # Salva temporaneamente i repo clonati (opzionale)
restart: unless-stopped
#volumes:
# mirror-data:
- Clone this repository:
git clone https://github.com/your-username/github-gitlab-mirror.git
cd github-gitlab-mirror
-
Edit
docker-compose.yml
and set your tokens and GitLab namespace. -
Build and start the container:
docker compose up -d --build
- Check logs:
docker compose logs -f
Edit crontab.txt
to change how often the mirror runs.
Default (every hour):
0 * * * * /mirror.sh >> /var/log/mirror.log 2>&1
Example: every 15 minutes:
*/15 * * * * /mirror.sh >> /var/log/mirror.log 2>&1
Temporary cloned repositories are stored in ./mirror-data
. This volume is not persistent across container restarts.
- Tokens are passed as environment variables.
- Do not commit or expose your tokens publicly.
MIT – Free to use and modify.