https://github.com/bocaletto-luca/gitlab-to-github-auto
GitLab to GitHub Auto Update Author: Bocaletto Luca 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 ...
https://github.com/bocaletto-luca/gitlab-to-github-auto
admin auto-import auto-update bocaletto-luca console github gitlab gitlab-to-github gitlab-to-github-migration linux opensource python script tool
Last synced: 7 months ago
JSON representation
GitLab to GitHub Auto Update Author: Bocaletto Luca 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 ...
- Host: GitHub
- URL: https://github.com/bocaletto-luca/gitlab-to-github-auto
- Owner: bocaletto-luca
- License: gpl-3.0
- Created: 2025-06-25T18:20:54.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-06-25T18:29:40.000Z (7 months ago)
- Last Synced: 2025-06-25T19:31:11.298Z (7 months ago)
- Topics: admin, auto-import, auto-update, bocaletto-luca, console, github, gitlab, gitlab-to-github, gitlab-to-github-migration, linux, opensource, python, script, tool
- Language: HTML
- Homepage: https://bocaletto-luca.github.io/
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GitLab to GitHub Auto Update
#### Author: Bocaletto Luca
**GitLab to GitHub Auto Update** is a Python tool that automates the import and synchronization of all your GitLab projects into GitHub. It will:
1. Fetch every project you’re a member of on GitLab.
2. Create a matching GitHub repo if it doesn’t already exist.
3. 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!
---
## Table of Contents
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
- [How It Works](#how-it-works)
- [Contributing](#contributing)
- [License](#license)
---
## Features
- **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.
---
## Requirements
- **Python 3.6+**
- **`requests` library**
```bash
pip install requests
```
- **GitLab Personal Access Token** with **`api`** scope
- **GitHub Personal Access Token** with **`repo`** scope
---
## Installation
1. **Clone this repository**
```bash
git clone https://gitlab.com/bocaletto-luca/gitlab-to-github-auto.git
cd gitlab-to-github-auto
```
2. **(Optional) Create & activate a virtual env**
```bash
python3 -m venv venv
source venv/bin/activate
```
3. **Install dependencies**
```bash
pip install requests
```
---
## Configuration
Open `gitlab_to_github_auto_update.py` and set:
```python
# 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`).
---
## Usage
Make the script executable and run:
```bash
chmod +x gitlab_to_github_auto_update.py
./gitlab_to_github_auto_update.py
```
Or simply:
```bash
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.
---
## How It Works
1. **Fetch Projects**
Requests `/projects?membership=true` on GitLab, handling pagination.
2. **Check/Create on GitHub**
For each project name, checks `GET /repos/{user}/{project}`. Creates via `POST /user/repos` if missing.
3. **Trigger Import**
Calls `PUT /repos/{user}/{project}/import` on GitHub, passing the GitLab HTTP URL plus credentials for private repos.
---
## Contributing
Bug reports, feature requests, and pull requests are welcome!
1. Fork the repo.
2. Create a feature branch.
3. Open a Merge Request here on GitLab.
---
## License
This project is licensed under the MIT License. See [LICENSE](LICENSE) for details.
---
*Made with ❤️ by bocaletto-luca*