How to Move/Migrate a Full Git Repository


In this post, I’ll show you how to move a full git repository from github to gitlab. We’ve an old repository existing on github and we wanted to move it to our gitlab, so Here’s the steps we did:

Step 1: Copy the entire repository

Run the following command to simply copy the entire repository “master and all branches” to your local machine under temp folder with any name:



$ git clone --mirror Mimastech_V2
Cloning into bare repository 'Mimastech_V2'...
remote: Counting objects: 193850, done.
remote: Compressing objects: 100% (70/70), done.
remote: Total 193850 (delta 1746), reused 1690 (delta 1690), pack-reused 192090
Receiving objects: 100% (193850/193850), 111.33 MiB | 831.00 KiB/s, done.
Resolving deltas: 100% (129942/129942), done.

For the above output, we cloned the entire repository into a temp folder called Mimastech_V2

Step 2: Check What You Cloned From Github

Now, we do a simple check on our repository, run the following command:

$ cd Mimastech_V2
$ git branch
* master

All branches are cloned.

Step 3: Remove Link to Old Repository

Now clear the link to the ORI repository with the following command:

 $ git remote rm origin
Note: Some branches outside the refs/remotes/ hierarchy were not removed;
to delete them, use:
 git branch -d 110
 git branch -d 111
 git branch -d hotfix
 git branch -d master

Step 4: Link Local Repository to the New one

Now link your local repository to your newly created NEW repository using the following command:

 $ git remote add origin <url to NEW repo>

Step 5: Push Local Repo to the New Repo

Now push all your branches and tags with these commands:

$ git push origin --all
Counting objects: 193819, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (59947/59947), done.
Writing objects: 100% (193819/193819), 111.32 MiB | 83.00 KiB/s, done.
Total 193819 (delta 129923), reused 193812 (delta 129916)
 * [new branch] 110 -> 110
 * [new branch] 111 -> 111
 * [new branch] hotfix -> hotfix
 * [new branch] master -> master

Now, Your repo moved from github to gitlab


If You Appreciate What We Do Here On Mimastech, You Should Consider:

  1. Stay Connected to: Facebook | Twitter | Google+
  2. Support us via PayPal Donate
  3. Subscribe to our email newsletters.
  4. Tell other sysadmins / friends about Us - Share and Like our posts and services

We are thankful for your never ending support.

Leave a Reply

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