This guide explains how to migrate your existing Git repositories from /home/mleku/Documents/github to your Gitea installation.
giteainstall.sh)http://your-vps-ip:3000 - read:repository
- write:repository
- read:user
- write:user
- Or simply select all scopes for convenience
On your local machine (where the repositories are), set up the configuration:
# Gitea API token (required)
export GITEA_TOKEN="your-token-here"
# Gitea URL (update with your VPS IP or domain)
export GITEA_URL="http://your-vps-ip:3000"
# VPS SSH connection (if migrating to remote server)
# Format: user@hostname or user@ip
export VPS_HOST="mleku@your-vps-ip"
# Source directory (default is /home/mleku/Documents/github)
export SOURCE_DIR="/home/mleku/Documents/github"
If Gitea is installed locally (on the same machine as the repos):
export GITEA_TOKEN="your-token-here"
export GITEA_URL="http://localhost:3000"
# Don't set VPS_HOST
Before actually migrating, do a dry run to see what would happen:
DRY_RUN=true ./scripts/gitea-migrate-repos.sh
This will:
Once you've verified the dry run looks good:
./scripts/gitea-migrate-repos.sh
The script will:
- Check if it already exists in Gitea - Create the repository via API (if it doesn't exist) - Push all branches and tags to Gitea - Report success or failure
After the migration completes:
http://your-vps-ip:3000The script supports several environment variables:
| Variable | Description | Default | Required |
|---|---|---|---|
GITEA_TOKEN | Gitea API token | - | Yes |
GITEA_URL | Gitea server URL | http://localhost:3000 | No |
VPS_HOST | SSH host for VPS | - | No (if local) |
SOURCE_DIR | Source repo directory | /home/mleku/Documents/github | No |
DRY_RUN | Dry run mode | false | No |
If migrating to a remote VPS, ensure SSH access is configured:
# Test SSH connection
ssh mleku@your-vps-ip
# Set up SSH key if not already done
ssh-copy-id mleku@your-vps-ip
By default, Gitea uses SSH port 2222 (to avoid conflicts with system SSH on port 22).
If you need to use a different SSH port, you'll need to:
/home/mleku/gitea/custom/conf/app.ini: `ini
[server]
SSHLISTENPORT = 2222 # Change this to your preferred port
`
`bash
sudo systemctl restart gitea
`
sudo systemctl status giteassh -p 2222 mleku@your-vps-ipsudo journalctl -u gitea -fThe script will skip repositories that already exist. You can:
Here's a complete example for migrating to a VPS:
# 1. Set up environment
export GITEA_TOKEN="a1b2c3d4e5f6g7h8i9j0"
export GITEA_URL="http://192.168.1.100:3000"
export VPS_HOST="mleku@192.168.1.100"
# 2. Test connection and do dry run
DRY_RUN=true ./scripts/gitea-migrate-repos.sh
# 3. Review output, then run actual migration
./scripts/gitea-migrate-repos.sh
# 4. Confirm when prompted
# Press 'y' to continue
# 5. Wait for migration to complete
# The script will show progress for each repository
# 6. Review summary
# Check for any failures and investigate
After successful migration:
`bash
cd /home/mleku/Documents/github/your-repo
git remote set-url origin http://your-vps-ip:3000/mleku/your-repo.git
`
`bash
git remote set-url origin ssh://mleku@your-vps-ip:2222/mleku/your-repo.git
`
`bash
git pull origin main
git push origin main
`
Your migration includes:
/home/mleku/Documents/githubIf you encounter issues:
sudo journalctl -u gitea -fGIT_TRACE=1 ./scripts/gitea-migrate-repos.sh