CLI script to interactively migrate repositories between organizations on the same Gitea instance via the Transfer Ownership API.
- Python 3.10+
- uv — fast Python package manager
# Clone the repo
git clone <repo-url>
cd gitea-move
# Install dependencies
uv syncCopy the example config and fill in your values:
cp .env.example .envEdit .env:
GITEA_URL=https://gitea.example.com
GITEA_TOKEN=your_api_token_here
Token permissions required:
user: read — required by the organizations list endpointorganization: read — to list organizationsrepository: write/admin — to transfer repositories
Generate a token at: https://<your-gitea>/user/settings/applications
uv run migrate.pyThe script will:
- Ask you to select the source organization
- Show a checkbox list of repos — select which ones to migrate (space to select, enter to confirm)
- Ask you to select the target organization
- Show a confirmation summary and ask to proceed
- Execute transfers and print a final summary
Example output:
? Select source organization: my-old-org
? Select repositories to transfer: done (3 selections)
? Select target organization: my-new-org
About to transfer 3 repo(s): my-old-org → my-new-org
- repo-alpha
- repo-beta
- repo-delta
? Proceed with transfer? No
Summary:
✓ repo-alpha → my-new-org
✓ repo-beta → my-new-org
✗ repo-delta FAILED: 422 Repository name already exists
Results: 2 succeeded, 1 failed
uv run --group dev pytest tests/ -v