# when you're ready.
$ bash migrate
This migration script assumes a number of things:
- You don't have a more elegant solution already.
- You are wanting to migrate all of the repos owned by a list of users from Gitea/Forgejo (
config:SOURCE_GIT
) and into GitLab (config:DESTINATION_GIT
). It does not matter if you are self-hosting or not, as long as you have both API and basic repo access. - You don't care about migrating all branches, and preserving
main
only is fine. - Your GitLab groups'/users' names (
config:NAMESPACES
) match your Gitea organizations'/users' names (config:OWNERS
) identically. See below for more. - You've stored your GitLab user/pass, if only temporarily, so you don't have to enter it on every
push
. - You have
jq
,git
, andcurl
installed. - You have admin access in GitLab.
- You have a GitLab personal access token with
api
scope (config:GITLAB_PAT
).
This migration script does the follow:
- Retrieves a list of repositories from Gitea/Forgejo via API. This ends up being a list of
owner/repo
strings saved intorepos.txt
. repos.txt
is read into a loop that iterates on each repo:- Create
repo
in destination GitLab via API. - Clone
repo
from Gitea. - Change
origin
inrepo
to GitLab. push main
to GitLab.
- Create
You need to add a config
bash script with the following contents:
#!/bin/bash
SOURCE_GIT=https://gitea
# Gitea/Forgejo repo owners
OWNERS=("[group name]" ...)
# GITLAB_PAT is NOT the same as your user PAT
GITLAB_PAT="[your GitLab API PAT]"
DESTINATION_GIT=https://gitlab
# GitLab groups and their namespace IDs
declare -A NAMESPACES=( ["group"]="namespace_id" ... )
Ignoring nuance, Gitea/Forgejo organizations are the same as GitLab groups.
In a perfect world, you're moving orgs into groups and the names are the same and it's no problem.
In an imperfect world, decide on your GitLab groups' names then change the Gitea/Forgejo organizations to whatever they will be in GitLab.
Otherwise you're going to need to do weird if-then or something and it just isn't worth it.
You're leaving Gitea/Forgejo behind, who cares what it looks like when the migration is over.