Skip to main content

Copy a Github public repository to a Gitlab self-hosted project

Project description

GitHub to GitLab

A simple command-line tool to copy a public GitHub repository to a GitLab project.

Description

GitHub to GitLab is a utility that allows you to easily migrate repositories from GitHub to GitLab. It automates the process of:

  1. Cloning a GitHub repository
  2. Creating a new project on GitLab (or using an existing one)
  3. Pushing all branches and tags to the GitLab project

This tool is particularly useful for:

  • Migrating projects from GitHub to self-hosted GitLab instances
  • Creating backups of GitHub repositories on GitLab
  • Setting up mirrors of public GitHub repositories

Installation

Prerequisites

  • Python 3.6 or higher
  • Git installed and configured on your system

Install from PyPI

pipx install hub_to_lab

Install from source

git clone https://github.com/RobinWoods/hub_to_lab.git
cd hub_to_lab
pip install -e .

Usage

Run the tool from the command line:

hub_to_lab

The tool will prompt you for:

  1. The GitHub repository to clone (in the format username/repository)
  2. The name for the new GitLab project

Environment Variables

The tool uses the following environment variables:

  • GITLAB_URL: The URL of your GitLab instance
  • GITLAB_TOKEN: Your GitLab personal access token
  • GITLAB_USERNAME: Your GitLab username
  • GITLAB_GROUP: The GitLab group where the project should be created

You can set these variables in a .env file in the current directory, or the tool will prompt you for them if they're missing.

Example .env file:

GITLAB_URL=https://gitlab.example.com
GITLAB_TOKEN=your_personal_access_token
GITLAB_USERNAME=your_username
GITLAB_GROUP=your_group

Features

  • Automatically creates a new GitLab project if it doesn't exist
  • Preserves all branches and tags from the GitHub repository
  • Shows progress with a nice progress bar
  • Stores configuration in a .env file for future use
  • Works with self-hosted GitLab instances

Dependencies

  • GitPython: For Git operations
  • rich: For progress bars and terminal output
  • python-dotenv: For environment variable management
  • requests: For GitLab API communication

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hub_to_lab-1.1.1.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hub_to_lab-1.1.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file hub_to_lab-1.1.1.tar.gz.

File metadata

  • Download URL: hub_to_lab-1.1.1.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.9.23 Linux/6.11.0-1018-azure

File hashes

Hashes for hub_to_lab-1.1.1.tar.gz
Algorithm Hash digest
SHA256 8c34a8aa6642d800f2bd2f7ef12beaf0318fb20c50c68078d0ab7d2f68a443a6
MD5 d8dca80b5e40e6853c9f5f68891ab570
BLAKE2b-256 08e62a94a481f73097d2cd62ec1cc025db3af61fcb98af007036a6dc11cb6f8b

See more details on using hashes here.

File details

Details for the file hub_to_lab-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: hub_to_lab-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.9.23 Linux/6.11.0-1018-azure

File hashes

Hashes for hub_to_lab-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bd36806c0767c18507bc9a7beb4c316d9d44560a378a8ee70a95d487a5b1e85d
MD5 2126209fc76927d5fa46f00691db261b
BLAKE2b-256 8a336d36d1fe03356a4bfc0ba73a1deb10bc2288bba63f6ae686ffb222c4deef

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page