Forking Git Repository From GitHub to GitLab
Last Updated :
23 Jul, 2025
Forking Git Repository from GitHub to GitLab allows you to make changes, experiment, or contribute to a project without affecting the source. This is useful when you want to work on open-source projects or collaborate with teams across different platforms.
In this article, we'll see how to Fork Git Repository From GitHub to GitLab, maintaining all the project history and branches.
Steps For Forking Git Repository From GitHub to GitLab
Step 1: Clone the GitHub Repository
git clone https://github.com/username/repository-name
cd repository-name
You must replace the "username" and "repository name" with your project requirements.
Step 2: Create a New GitLab Repository
Once we are done with cloning the repository in our system, now our new task is to create a new GitLab repository, which we can be created by navigating directly to the plus icon at the top.
Step 3: Add the GitLab Remote to Your Local Repository
Next, we need to add the GitLab repository as a remote to our local repository which we can do by entering the following command.
git remote add gitlab https://gitlab.com/users/sign_in
Step 4: Push the Repository to GitLab
Now it's time to push the cloned repository to our created GitLab repository by using the following command.
git push gitlab main
See we are pushing to the main branch in our case you can change for yourself
Step 5: Set GitLab as the Default Remote (Optional)
This going to be an optional task which can be skipped but those who want to use gitlab primarily, they can remove the current remote and then rename the gitlab remote to the origin by usng the following command
git remote remove origin
git remote rename gitlab origin
Example 1: Cloning and Adding GitLab as Remote
For this article we are considering a project named "OLauncher" which is hosted on Github which we are going to fork on Gitlab.
Step 1: First we Clone Repo to our Local system Using This command
git clone https://github.com/tanujnotes/Olauncher
Git cloneStep 2: Create a new Gitlab repository naming "OLauncher"
Step 3: Add a remote for Gitlab
git remote add gitlab https://gitlab.com/users/sign_in
Gitlab Repo
Step 4: Know the Git Branch
git branch -v
git branch -vStep 5: Push the Repo to the branch from the local System to Gitlab
git push gitlab master
git push
Forking Git Repository From GitHub to GitLabExample 2: Removing GitHub Remote and Renaming GitLab
If we want to remove Github connection and focus solely on Gitlab. As said Earlier this is an Optional case
git remote remove origin
git remote rename gitlab origin
By Following this Guide we can fork any project from Github to Gitlab with ease.
Explore
Git Introduction
Git Installation and Setup
All Git Commands
Most Used Git Commands
Git Branch
Git Merge
Git Tools and Integration
Git Remote Repositories
Collaborating with Git
Advanced Git Commands