DevOps

Migrating from GitLab to GitHub (Without the Baggage of Large Files)

When working with large data or heavy dependencies, it’s not uncommon for repositories to exceed GitHub’s 100MB file size limit. If you’re migrating from GitLab to GitHub and encounter this issue, you’ll need to clean your repo history and strip out large files before pushing.

In this post, I’ll walk you through how to successfully import your GitLab repo to GitHub while removing large files and their history using git-filter-repo.


🚧 The Problem

During a migration, you may run into an error like:

Files above push limit detected. Use Git LFS or remove the large files from the git history...

GitHub strictly enforces a 100MB limit on individual files. Large files such as .hprof, .csv, .zip, or binary artifacts can block your push — even if they were deleted in a later commit.

This happens because Git stores the entire commit history, including past versions of large files. So even a long-deleted file can cause a migration to fail.


Step-by-Step Solution

1. Clone Your GitLab Repo

git clone --mirror https://gitlab.com/your-user/your-repo.git
cd your-repo.git

Use --mirror so you get the full history and all branches/tags.


2. Identify Large Files (Optional)

To see which files are problematic, you can use:

git verify-pack -v objects/pack/pack-*.idx | sort -k 3 -n | tail -10

But GitHub’s error message will often give you the exact file paths and sizes.


3. Create a File List

Create a text file named files-to-remove.txt with the paths of the large files. For example:

src/android/android/java_pid1350.hprof
src/android/android/java_pid631.hprof

4. Remove Large Files From History

Install git-filter-repo if you haven’t already:

brew install git-filter-repo  # macOS
sudo apt install git-filter-repo  # Ubuntu/Debian

Then run:

git filter-repo --invert-paths --paths-from-file files-to-remove.txt

This will rewrite your repo history, excluding the listed files.


5. Push to GitHub

Now you’re ready to push the cleaned repo:
git remote add github https://github.com/your-user/your-repo.git

git push github --mirror

Leave a Reply

Your email address will not be published. Required fields are marked *