No description
- Python 100%
| .vscode | ||
| .env.example | ||
| .gitignore | ||
| migrate-all.py | ||
| migrate-one.py | ||
| readme.md | ||
| utils.py | ||
Gitea Migration Script
This Python script facilitates the migration of repositories from a source Gitea instance to a destination Git service (such as GitHub or another Git-compatible platform that supports repository migration via API).
Features
- Bulk Migration: Migrate all repositories from a Gitea instance that match specified criteria
- Single Repository Migration: Interactive migration of individual repositories
- Comprehensive Migration: Includes pull requests, issues, labels, LFS files, milestones, releases, and wiki pages
- Filtering: Use whitelist and blacklist to control which repositories are migrated
- Error Handling: Graceful handling of existing repositories and API errors
Environment Variables
Set the following environment variables before running the scripts:
SOURCE_GITEA_TOKEN: Personal access token for the source Gitea instanceDESTINATION_GIT_TOKEN: Personal access token for the destination Git serviceSOURCE_GITEA_URL: Base URL of the source Gitea instance (e.g.,https://gitea.example.com)DESTINATION_GIT_URL: Base URL of the destination Git service API (e.g.,https://api.github.comfor GitHub)BLACKLIST: Comma-separated list of repository names or organizations to exclude from migrationOWNER_WHITELIST: Comma-separated list of organization names that are allowed for migration
Usage
Bulk Migration
Run migrate-all.py to migrate all repositories that match the whitelist criteria:
python migrate-all.py
This script will:
- Fetch all repositories from the source Gitea instance
- Filter repositories based on whitelist and blacklist
- Migrate each qualifying repository to the destination
Single Repository Migration
Run migrate-one.py for interactive migration of individual repositories:
python migrate-one.py
Follow the prompts to enter repository URLs one by one. The script will continue until you interrupt it (Ctrl+C).
Migration Details
The migration process includes:
- Repository code and history
- Pull requests
- Issues
- Labels
- LFS (Large File Storage) files
- Milestones
- Releases
- Wiki pages
Note: The destination service must support the repository migration API endpoint used by this script.
Error Handling
- If a repository already exists at the destination, the script will skip it and continue
- API errors are displayed with details
- The script will exit on critical errors during migration
Security Notes
- Store access tokens securely and never commit them to version control
- Use environment variables or secure credential management
- Ensure tokens have appropriate permissions for repository operations
Contributing
Contributions are welcome!