How To Import A Copy of An Existing GitLab project

Problem scenario:  You want to copy a GitLab project from one instance of GitLab to a new instance of GitLab.  The Git repository you want to copy to a new GitLab server is not presented via the git://, http://, nor https:// protocols.    

Prerequisites:  You have root access to the back end of the server with the GitLab.

Method of Solution:
1)  Go to /var/opt/gitlab/git-data/repositories/root/<nameOfProject>.git  

2)  Copy it to a staging area of the destination server.

3)  Make sure every user has logged off the destination GitLab server.  This avoids confusion of shutting things down when someone is trying to check code in.

4)  Log into the web UI of the GitLab instance that is the destination of this copy task. Create a new project with the name <nameOfProject> (with no .git extension).  

5)  Go to the back end of the GitLab server that is the destination of this copy task.  As root run this command:
rm -rf /var/opt/gitlab/git-data/repositories/root/<nameOfProject>.git  

6)  Copy the file in step 2 to /var/opt/gitlab/git-data/repositories/root/

7)  Run this command:  chmod git:git /var/opt/gitlab/git-data/repositories/root/<nameOfProject>.git

8)  Stop the GitLab service.  Restart it.

Leave a comment

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