- A GitLab repository (source)
- A GitHub repository (target), which can be empty or already contain the same content
- Admin/Maintainer access to the GitLab project
- A GitHub account with write access to the target repository
- Go to GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens. You are asked to authenticate with your GitHub account.
- Click Generate new token
- Configure the token:
- Token name: choose a descriptive name (e.g.,
Test_token)
- Expiration: choose an appropriate duration
- Resource owner: select the organization that owns the target repo (e.g.,
agroscope-ch), or your personal account - Repository access: select Only select repositories and pick the target repository

- Permissions → Repository permissions → Contents: set to Read and Write

- Token name: choose a descriptive name (e.g.,
- Click Generate token
- Copy the token immediately (it starts with
github_pat_...). You won't be able to see it again.
- Your administrator must validate your token (you will see a label pending until it is activated)

Before setting up mirroring, you have to make sure
- that the GitHub repo is up to date with GitLab
- that your personnal access token is activated
No action needed — GitLab will push everything on the first mirror sync.
From your local GitLab clone, add GitHub as a temporary remote and mirror-push:
cd /path/to/your/gitlab/repo
git remote add github https://github.com/<org>/<repo>.git
git push github --mirror
git remote remove githubThis force-pushes all branches, tags, and refs to GitHub.
- Go to your GitLab project's web interface
- Navigate to Settings → Repository

- Expand the Mirroring repositories section
- Fill in the fields:
- Git repository URL:
https://github.com/<org>/<repo>.git. In our example, it ishttps://github.com/agroscope-ch/test.git - Mirror direction: Push (no choice)
- Authentication method: Username and Password (no choice)
- Username: your personal GitHub username (the account that owns the token, not the organization name)
- Password: the full token including the
github_pat_prefix.
- Git repository URL:
- Click Mirror repository
- After saving, you should see the mirror listed with a status indicator

- Click the Update now button (refresh icon) to trigger an immediate sync
- Check the GitHub repository to confirm the content matches GitLab. It now looks like the Gitlab repository

- Every time you
git pushto GitLab, it automatically pushes to GitHub - GitLab also periodically syncs (typically every 5 minutes)
- The mirror uses force push, so GitHub always matches GitLab exactly
- Treat GitHub as read-only. Any commits pushed directly to GitHub will be overwritten by the next mirror sync.
- If the token expires, the mirror will stop working. You'll need to regenerate a token and update the password in GitLab's mirroring settings.
- Fine-grained tokens must be scoped to the specific repository with Contents: Read and Write permission.
