Importing a Git repo into GitHub is a common task that can be accomplished using either the GitHub web interface or command-line tools. Many developers work with different Git hosting services like GitLab, Gitee, or Bitbucket, and might find themselves needing to move their projects to GitHub for various reasons such as better integration with other tools, more robust community support, or enhanced project visibility. This blog will guide you through both methods of importing your repository into GitHub, ensuring you can effortlessly manage your projects.
Method 1(Recommended): Import Repo into GitHub Using the GitHub Web Interface
The GitHub web interface provides a straightforward way to import your repository. Follow these steps:
1. Log in to GitHub
Open your browser and go to GitHub. Log in with your credentials.
2. Find Import Repository Icon
Do NOT create a new git repository. We’ll import it directly. The import icon is likely to be in the upper right corner of the page.

3. Import your project to GitHub
The next page is very intuitive. Use your current project’s URL, username and password to import it into Github. It’s that simple.

4. Complete the Import
GitHub will start importing your repository. You can leave the page. You’ll be notified once the import is complete, and you can begin working with your imported repository.
Method 2: Import Repo into GitHub Using the Command Line
Alternatively, if you would like to know what happens under the hood, you can use the command line to import a repository. This helps us to understand that migrating a repository is effectively changing a repo’s remote. Here’s how:
- Clone the Existing Repository (if you don’t already have a local copy):
git clone https://gitlab.com/old-repository-url.git new-repository-directory cd new-repository-directory
If you already have the repository locally, navigate to that directory:
cd path/to/your/git-directory
- Remove the Existing Remote (optional but recommended):
git remote remove origin
- Rename the Current Repository (if necessary): You can rename the directory to reflect the new repository name:
cd .. mv old-repository-directory new-repository-name cd new-repository-name
- Create a New Repository on GitHub: Go to your GitHub account, click on the
+
icon at the top right corner, and selectNew repository
. Fill in the necessary details and create the repository. Copy the URL of the new repository. - Add the New Remote:
git remote add origin https://github.com/your-username/new-repository.git
- Push to the New Repository: Push all branches and tags to the new repository:
git push -u origin --all git push origin --tags
- Verify: Check that everything has been pushed correctly by visiting the new repository URL in your browser.
Conclusion
Whether you prefer the simplicity of the GitHub web interface or the power and flexibility of the command line, importing a Git repository into GitHub is a straightforward process. By following the steps outlined in this blog, you can seamlessly transition your projects from other Git hosting services like GitLab, Gitee, or Bitbucket to GitHub and take advantage of its robust version control and collaboration features. Happy coding!