What connects nearly all developers in the world? Version control systems! Whether you are just at the beginning of your programming journey or you are a dinosaur in the industry, for sure you use it. And probably it’s Git which is the most common and widely used. But for sure you need to host it somewhere. One of the best-known version control hosting platforms is GitLab.
Git repository – how does architecture look like
We will try to explain how to clone a GitLab project. But first, we have to understand the basics and how Git works itself. We call it a distributed version control system. It means that every copy is a 1:1 mapping of the repository. So basically, all copies are equal. There is always one repo in a GitLab project, that we call origin that integrates all additional repos. The origin is the most up-to-date version that is usually downloaded to work on a specific project.
So in short – cloning is all about downloading the entire project. So then our history and commits are fetched as well. As a result our local copy will be a 1:1 origin version.
Git clone in GitLab
The clone function can be parameterized, like most of Git functions. Parameters change its default behaviour but are optional. Required is the address of our origin (remote repository) and the local directory where we want to place our copied project.
git clone <repo_address> <directory>
This address is usually HTTPS of the project website like for example the Inkspace project – open source, free vector graphics editor, available here: https://gitlab.com/inkscape/inkscape
While entering this page you will find the “Clone” button. It allows you to clone a GitLab repository. Once clicked, the below window will open:
Here you can see two options:
- Clone with HTTPS
- Clone with SSH
What are the differences between a GitLab clone with SSH and a clone with HTTPS? Well, those are basically two completely different communication protocols. But once it comes to cloning action, the difference is irrelevant. In the case of SSH, it is obligatory to create a key pair and put the public key in the GitLab account settings. Then you just need to provide the appropriate address for the protocol.
GitLab backup
Git clone and GitLab should never be treated as a backup and we should take care of it on our own. Preparing the correct scripts for GitLab backup, and of course another for restoration, is difficult and time-consuming. So the experts recommend having a third-party GitLab backup software like GitProtect.io to save time, resources and money in a long-term perspective.
GitLab clone is a concept that requires mainly basic knowledge. More advanced is using HTTPS and SSH. However, we should never forget about a reliable GitLab backup to always be prepared for the worst.