Skip to content

plitto007/gitlab-2-github-migration

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitLab to GitHub Migration Tool

This tool is a Python script designed to automate the migration of Git repositories from a GitLab instance to a GitHub organization. It handles the creation of the repository on GitHub, mirrors the entire Git history, and assigns the new repository to a specified team within your GitHub organization.

The migration process is managed through a simple CSV file, allowing for easy batch processing of multiple repositories.


Features

  • Batch Migration: Migrates multiple repositories defined in a repo_url.csv file.
  • Organization & Team Support: Automatically creates repositories within a specified GitHub organization.
  • Team Assignment: Adds the newly migrated repository to a designated team with push permissions.
  • Full History Mirror: Uses git clone --bare and git push --mirror to ensure all branches and tags are migrated perfectly.
  • Idempotent Creation: Safely skips repository creation on GitHub if the repository already exists, preventing errors on re-runs.
  • Secure: Uses environment variables to handle sensitive access tokens securely.

Prerequisites

Before you begin, ensure you have the following:

  1. Python 3: The script is written in Python 3.
  2. Git: The Git command-line tool must be installed and accessible in your system's PATH.
  3. Python Dependencies: The requests library is required. Install it via pip:
    pip install requests
  4. GitLab Personal Access Token:
    • Create a token in your GitLab account with read_api and read_repository scopes.
    • Go to User Settings > Access Tokens.
  5. GitHub Personal Access Token (Classic):
    • Create a token in your GitHub account. For organization migrations, it's recommended to use a token from an organization owner.
    • Required scopes:
      • repo: For creating and writing to repositories.
      • admin:org: For adding repositories to teams.
    • Go to Developer settings > Personal access tokens > Tokens (classic).

Configuration

1. Environment Variables

This script relies on environment variables for configuration and credentials. Create a .env file in the project root or export them in your shell session.

# GitLab Configuration
GITLAB_URL="[https://gitlab.com](https://gitlab.com)"  # Optional: Defaults to gitlab.com if not set
GITLAB_TOKEN="your_gitlab_personal_access_token"

# GitHub Configuration
GITHUB_TOKEN="your_github_personal_access_token"
GITHUB_USER_NAME="your_github_username" # The username associated with the GITHUB_TOKEN
GITHUB_REPO_PRIVATE="True" # Set to "True" for private repos, "False" for public

About

GitLab to GitHub Migration Tool

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published