I was recently trying to import some repositories from GitLab to GitHub, and kept receiving an error the title "We found an error during import" and message "There was an error pushing commits to GitHub." This is a pretty generic error message and didn’t give me much to go on to start figuring out why the GitHub repository import process was failing.
I started to wonder if the username and password (or access token) combination I had provided was incorrect, but they worked when cloning the repository to my machine. I asked a colleague to attempt to import the repository to their GitHub account and it surprised me when it was successful.
This meant it must be something about my GitHub or GitLab account settings that was causing the importer to fail.
After digging through the GitHub and GitLab settings pages, we came across the "Block command line pushes that expose my email" setting. When enabled, this option prevents you from pushing commits to GitHub which contain an email address that is connected to your GitHub account.
Every commit has an email address associated with it which can be seen by anyone who is able to view the repository. This setting is intended to prevent you from unintentionally making your email address public. GitHub provides you with a private email address to use instead, which allows you to push new commits to your repository.
The solution for me was to temporarily disable this option by unticking the "Block command line pushes that expose my email" setting on GitHub. This allowed me to import the repositories successfully. I could then safely re-enable the setting again if needed.
It would be nice if GitHub repository importer could provide some more details on the reason for the GitHub repository import process failing. It would have saved a lot of time in troubleshooting the issue, if it had said the repository was rejected due to commits containing my email address.
In my case the GitLab repository was being blocked by the GitHub repository import process because the commits contained my email address. I had enabled the "Block command line pushes that expose my email" setting in the Emails section of my GitHub account settings, which was causing this to happen. After temporarily disabling this option, the GitHub importer was able to import the GitLab repository successfully.