GitLab to GitHub Auto Update is a Python tool that automates the import and synchronization of all your GitLab projects into GitHub. It will:
- Fetch every project you’re a member of on GitLab.
- Create a matching GitHub repo if it doesn’t already exist.
- Invoke GitHub’s “Import Repository” API to pull from GitLab (using your GitLab credentials for private repos).
Ideal if you manage hundreds of repos and want a hands-free mirror on GitHub!
- Bulk Sync: Loops through all your GitLab projects in one go.
- Auto-Create: Creates GitHub repos on demand (public or private).
- Seamless Imports: Kicks off GitHub’s official Import API for mirroring.
- Handles Privacy: Passes your GitLab token when importing private repos.
- Python 3.6+
requests
librarypip install requests
- GitLab Personal Access Token with
api
scope - GitHub Personal Access Token with
repo
scope
-
Clone this repository
git clone https://gitlab.com/bocaletto-luca/gitlab-to-github-auto.git cd gitlab-to-github-auto
-
(Optional) Create & activate a virtual env
python3 -m venv venv source venv/bin/activate
-
Install dependencies
pip install requests
Open gitlab_to_github_auto_update.py
and set:
# GitLab settings
GITLAB_URL = "https://gitlab.com/api/v4"
GITLAB_TOKEN = "your_gitlab_token_here"
GITLAB_USERNAME = "your-username"
# GitHub settings
GITHUB_API_URL = "https://api.github.com"
GITHUB_TOKEN = "your_github_token_here"
GITHUB_USERNAME = "your-username"
Security Note:
Never commit your tokens in plaintext. Use environment variables or a.env
file (excluded via.gitignore
).
Make the script executable and run:
chmod +x gitlab_to_github_auto_update.py
./gitlab_to_github_auto_update.py
Or simply:
python3 gitlab_to_github_auto_update.py
You’ll see console output for each project—whether it was created or already existed, and the status of the import trigger.
-
Fetch Projects
Requests/projects?membership=true
on GitLab, handling pagination. -
Check/Create on GitHub
For each project name, checksGET /repos/{user}/{project}
. Creates viaPOST /user/repos
if missing. -
Trigger Import
CallsPUT /repos/{user}/{project}/import
on GitHub, passing the GitLab HTTP URL plus credentials for private repos.
Bug reports, feature requests, and pull requests are welcome!
- Fork the repo.
- Create a feature branch.
- Open a Merge Request here on GitLab.
This project is licensed under the MIT License. See LICENSE for details.
Made with ❤️ by bocaletto-luca