How to migrate a git repository from gitlab self-hosted to gitlab.com
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
If you are new to git and want to learn more, the doc section of the official site is full of content.
Gitlab can be installed on your local server or you can create your own repositories on gitlab.com; in both cases, your repositories can be public or private.
In this article I don’t want to discuss which of the two solutions is the best: it’s better to have a local installation that you have under control but that you have to maintain and update or it’ better to use the gitlab.com platform? The decision it’s up to you!
In this article I want to help you to migrate your projects from a self-hosted installation to gitlab.com without losing any information about the repository.
Here the step:
- create a new user on gitlab.com and login
- create a new blank project in gitlab.com (without create README or any file)
- follow this steps in the terminal on your PC
- archive the project in your self-hosted gitlab [optional step]
settings - general - archive project
This is useful step because it saves you from making changes in the old project by mistake.
- tell to people who work on the project, to change the remote pointer and moving to the new repository hosted by gitlab.com with this command:
git remote set-url origin email@example.com:yourGroup/yourProject.git
With this procedure you will move all your code (including branches and commits) to gitlab.com, thus keeping all the historicity of the project.
NB what you will not be able to migrate with this procedure: issue and merge requests
For newbies, you can find a great freecodecamp article “What is Git? A Beginner’s Guide to Git Version Control” here https://www.freecodecamp.org/news/what-is-git-learn-git-version-control/
Thanks a lot for reading, sharing and comment this article