A TypeScript tool to migrate all your GitHub or GitLab repositories to Codeberg with a single command.
- Fetch all your GitHub or GitLab repositories (public, private, and forks)
- Create corresponding repositories on Codeberg
- Clone and push all branches and tags from source to Codeberg
- Preserve commit history and repository metadata
- Handle both public and private repositories
- Support for both GitHub and GitLab sources
- Check for existing repositories on Codeberg to avoid duplicates
- Option to delete source repositories after successful migration (DANGEROUS)
- Node.js (v16 or later) OR Bun
- Git
- GitHub Personal Access Token with appropriate scopes (if migrating from GitHub)
- GitLab Personal Access Token with appropriate scopes (if migrating from GitLab)
- Codeberg Personal Access Token with appropriate scopes
-
Clone this repository:
git clone <repository-url> cd github-to-codeberg-migrator
-
Install dependencies:
npm install
-
Create a
.envfile in the root directory:cp .env.local .env # Copy the example file -
Configure your environment variables in the
.envfile:GITHUB_TOKEN: Your GitHub Personal Access Token (required if migrating from GitHub)GITLAB_TOKEN: Your GitLab Personal Access Token (required if migrating from GitLab)CODEBERG_TOKEN: Your Codeberg Personal Access Token (required)GITHUB_USERNAME: Your GitHub username (required if migrating from GitHub)GITLAB_USERNAME: Your GitLab username (required if migrating from GitLab)CODEBERG_USERNAME: Your Codeberg username (required)CODEBERG_BASE_URL: Your Codeberg instance URL (optional, defaults to https://codeberg.org)
-
Clone this repository:
git clone <repository-url> cd github-to-codeberg-migrator
-
Install dependencies:
bun install
-
Create a
.envfile in the root directory:cp .env.local .env # Copy the example file -
Configure your environment variables in the
.envfile:GITHUB_TOKEN: Your GitHub Personal Access Token (required if migrating from GitHub)GITLAB_TOKEN: Your GitLab Personal Access Token (required if migrating from GitLab)CODEBERG_TOKEN: Your Codeberg Personal Access Token (required)GITHUB_USERNAME: Your GitHub username (required if migrating from GitHub)GITLAB_USERNAME: Your GitLab username (required if migrating from GitLab)CODEBERG_USERNAME: Your Codeberg username (required)CODEBERG_BASE_URL: Your Codeberg instance URL (optional, defaults to https://codeberg.org)
- Go to GitHub Settings > Developer settings > Personal access tokens > Tokens (classic)
- Click "Generate new token"
- Select the following scopes:
repo(for private repositories) orpublic_repo(for public repositories only)read:org(if you have organization repositories)read:user(to read user profile)user:email(to read email addresses)
- Generate the token and copy it
- Go to GitLab Settings > Access Tokens
- Click "New personal access token"
- Select the following scopes:
read_api(to read projects)read_repository(to clone repositories)write_repository(to push to repositories)
- Generate the token and copy it
- Go to Codeberg Settings > Applications > Personal Access Tokens
- Click "Generate New Token"
- Select the following scopes:
repo(for private repositories) orpublic_repo(for public repositories only)
- Generate the token and copy it
npm run migrate:github
# or
npx ts-node migrate-universal-to-codeberg.ts --source githubnpm run migrate:gitlab
# or
npx ts-node migrate-universal-to-codeberg.ts --source gitlabnpx ts-node migrate-universal-to-codeberg.ts --source github --include-forks
# or
npx ts-node migrate-universal-to-codeberg.ts --source gitlab --include-forksnpx ts-node migrate-universal-to-codeberg.ts --source github --include-forks --delete-source
# or
npx ts-node migrate-universal-to-codeberg.ts --source gitlab --include-forks --delete-sourcenpm run migrate:github:delete
# or
npm run migrate:gitlab:deleteIMPORTANT: This option will delete repositories from the source platform (GitHub/GitLab) after they have been successfully migrated to Codeberg. This action is irreversible. The script will give you 10 seconds to cancel by pressing Ctrl+C before proceeding.
npm run build
npm run startbun run migrate-universal-to-codeberg.ts --source github
# or
bun run migrate:bun:githubbun run migrate-universal-to-codeberg.ts --source gitlab
# or
bun run migrate:bun:gitlabbun run migrate-universal-to-codeberg.ts --source github --include-forks
# or
bun run migrate-universal-to-codeberg.ts --source gitlab --include-forksbun run migrate-universal-to-codeberg.ts --source github --include-forks --delete-source
# or
bun run migrate-universal-to-codeberg.ts --source gitlab --include-forks --delete-sourcebun run migrate-universal-to-codeberg.ts --source github --delete-source
# or
bun run migrate-universal-to-codeberg.ts --source gitlab --delete-sourceIMPORTANT: This option will delete repositories from the source platform (GitHub/GitLab) after they have been successfully migrated to Codeberg. This action is irreversible. The script will give you 10 seconds to cancel by pressing Ctrl+C before proceeding.
bun run dev:bunbun run build
bun run start| Variable | Description | Required |
|---|---|---|
GITHUB_TOKEN |
GitHub Personal Access Token | Only if migrating from GitHub |
GITLAB_TOKEN |
GitLab Personal Access Token | Only if migrating from GitLab |
CODEBERG_TOKEN |
Codeberg Personal Access Token | Yes |
GITHUB_USERNAME |
Your GitHub username | Only if migrating from GitHub |
GITLAB_USERNAME |
Your GitLab username | Only if migrating from GitLab |
CODEBERG_USERNAME |
Your Codeberg username | Yes |
CODEBERG_BASE_URL |
Your Codeberg instance URL | No (defaults to https://codeberg.org) |
The migration script will:
- Fetch all your GitHub or GitLab repositories (excluding forks by default)
- Check if repositories already exist on Codeberg to avoid duplicates
- Create new repositories with the same name on Codeberg (if they don't exist)
- Clone each repository from the source (GitHub or GitLab)
- Push all branches and tags to Codeberg
- Preserve commit history and repository settings
- Optionally delete source repositories after successful migration
--delete-source flag will permanently delete repositories from GitHub/GitLab after successful migration. This action is irreversible. Only use this option when you're certain your data is safely migrated to Codeberg.
- If you get authentication errors, verify that your tokens are correct and have the required scopes
- For large repositories, the migration may take a while
- If the migration fails for a specific repository, check the error output for details
- Make sure you have enough storage space on Codeberg for all your repositories
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.