Gitea Mirror auto-syncs GitHub repos to your self-hosted Gitea/Forgejo, with a sleek Web UI and easy Docker deployment.
Gitea Mirror
Automatically mirror repositories from GitHub to your self-hosted Gitea/Forgejo instance.
Quick Start
bash
# Fastest way - using the simplified Docker setup
docker compose -f docker-compose.alt.yml up -d
# Access at http://localhost:4321
First user signup becomes admin. Configure GitHub and Gitea/Forgejo through the web interface!
Full documentation - quickstart, deployment, configuration, notifications, SSO and more. Offline copies live in docs/.
✨ Features
Mirror public, private, and starred GitHub repos to Gitea/Forgejo
Multiple sources (GitLab and Gitea/Forgejo beta) - Connect several sources at once: GitHub and GitHub Enterprise, GitLab, Gitea/Forgejo, and each repository keeps its source. gitlab.com, Codeberg and self hosted instances mirror code, tags, wiki and LFS (issues, pull requests and releases need a GitHub source). GitHub to Gitea is the supported default; every other source or destination is beta. See docs/SOURCE_PROVIDERS.md
️ GitHub Enterprise support - Works with GHES and GHEC with data residency via GH_API_URL
Forgejo, GitHub and GitLab destinations (beta) - Forgejo works like Gitea. Pick GitHub or GitLab and the app keeps a bare clone of each repository and pushes its branches and tags there. Code only, and the target is overwritten on every sync. See docs/PUSH_TARGETS.md
Mirror entire organizations with flexible strategies, including public organizations from GitHub, GitLab or Gitea/Forgejo with no source account configured
Custom destination control for repos and organizations
Minimal .env file (optional - has sensible defaults):
bash
# Custom port (default: 4321)
PORT=4321
# User/Group IDs for file permissions (default: 1000)
PUID=1000
PGID=1000
# Session secret (auto-generated if not set)
BETTER_AUTH_SECRET=your-secret-key-change-this-in-production
All other settings are configured through the web interface after starting.
Full Setup Configuration (docker-compose.yml)
Supports extensive environment variables for automated deployment. See the full docker-compose.yml for all available options including GitHub tokens, Gitea URLs, mirror settings, and more.
# Run immediately - no setup needed!
nix run --extra-experimental-features 'nix-command flakes' github:RayLabsHQ/gitea-mirror
# Or build and run locally
nix build --extra-experimental-features 'nix-command flakes'
./result/bin/gitea-mirror
# Or install to profile
nix profile install --extra-experimental-features 'nix-command flakes' github:RayLabsHQ/gitea-mirror
gitea-mirror
NixOS users - add the flake input, import the module, then enable the service:
Configure the source and destination connections. GitHub to Gitea is the default. Forgejo works like Gitea, and GitHub or GitLab as destination uses push targets. Everything other than GitHub to Gitea is beta
Single Organization: All repos go to one Gitea/Forgejo organization
Flat User: All repos under your Gitea/Forgejo user account
Mixed Mode: Personal repos in one org, organization repos preserve structure
Customization
Click edit buttons on organization cards to set custom destinations
Override individual repository destinations in the table view
Starred repositories can go to a dedicated org or preserve source owner/org paths
Advanced Features
Git LFS (Large File Storage)
Mirror Git LFS objects along with your repositories:
Enable "Mirror LFS" option in Settings → Mirror Options
Requires Gitea/Forgejo server with LFS enabled (LFS_START_SERVER = true)
Requires Git v2.1.2+ on the server
Metadata Mirroring
Transfer complete repository metadata from GitHub to Gitea/Forgejo:
Issues - Mirror all issues with comments and labels
Pull Requests - Transfer PR discussions to Gitea/Forgejo
Labels - Preserve repository labels
Milestones - Keep project milestones
Wiki - Mirror wiki content
Releases - Transfer GitHub releases with assets
Releases have two limits. The release limit keeps only the newest N releases in Gitea/Forgejo. The release asset limit uploads assets only for the newest N of those, so a repository with years of releases can keep every release note and tag while only the recent binaries take up space. Leave the asset limit empty to upload assets for every mirrored release, or set it to 0 for release notes only. Both limits can be overridden per organization and per repository, and lowering the asset limit never deletes assets that were already uploaded.
Enable in Settings → Mirror Options → Mirror metadata
Repository Management
Ignore Status - Mark repositories to skip from mirroring
Automatic Cleanup - Configure retention period for activity logs
Scheduled Sync - Set custom intervals for automatic mirroring
Reconcile with Destination - Compare Gitea/Forgejo with the database from Configuration > Automation: adopt mirrors the database lost track of, record the new owner of mirrors you transferred in Gitea, or reset rows whose mirror is gone so the next sync recreates them. Nothing is deleted or archived by this step.
Move Mirrors from the App - Changing a repository's or an organization's destination offers to transfer the existing mirrors on Gitea/Forgejo as well, with their history, issues and mirror settings. When the token cannot create repositories under the new owner, Gitea asks its owners to accept and sync follows the mirror once they do.
Smart scheduling: Only syncs repositories that need updating
Auto-start on boot (v3.5.3+): Automatically imports and mirrors all repositories when SCHEDULE_ENABLED=true or GITEA_MIRROR_INTERVAL is set - no manual clicks required!
Configuration via Web Interface (Recommended)
Navigate to the Configuration page and enable "Automatic Syncing" with your preferred interval.
Configuration via Environment Variables
** Set it and forget it!** With these environment variables, Gitea Mirror will automatically:
Import all your GitHub repositories on startup (no manual import needed!)
Mirror them to Gitea/Forgejo immediately
Keep them synchronized based on your interval
Auto-discover new repos you create/star on GitHub
Clean up repos you delete from GitHub
…
Important Notes:
Auto-Start: When SCHEDULE_ENABLED=true or GITEA_MIRROR_INTERVAL is set, the service automatically imports all GitHub repositories and mirrors them on startup. No manual "Import" or "Mirror" button clicks required!
The scheduler checks every minute for tasks to run. The GITEA_MIRROR_INTERVAL determines how often each repository is actually synced. For example, with 8h, each repo syncs every 8 hours from its last successful sync.
Large repo bootstrap: For first-time mirroring of large repositories (especially with metadata/LFS), avoid very short intervals (for example 5m). Start with a longer interval (1h to 8h) or temporarily disable scheduling during the initial import/mirror run, then enable your regular interval after the first pass completes.
Why this matters: If your Gitea/Forgejo instance takes a long time to complete migrations/imports, aggressive schedules can cause repeated retries and duplicate-looking mirror attempts.
️ Backup Protection Features:
No Accidental Deletions: Repository cleanup is automatically skipped if GitHub is inaccessible (account deleted, banned, or API errors)