GitLab is a popular platform for managing Git repositories, offering robust tools for collaboration and CI/CD. One of the first steps when working with a GitLab project is cloning it to your local machine.
This guide walks you through how to clone a GitLab repository using HTTPS or SSH.
๐ What Does โCloningโ Mean?
Cloning a repository means youโre creating a local copy of a GitLab project on your machine so you can work on it, commit changes, and push updates.
๐ Prerequisites
Make sure you have:
- Git installed on your machine (run
git --version
to verify) - Access to the GitLab repository URL
- Proper authentication (GitLab account with permissions, SSH key or access token, depending on method)
๐ Step 1: Copy the Repository URL
- Go to the GitLab repository in your browser.
- Click the Clone button (top right or sidebar).
- Choose either:
- HTTPS URL: starts with
https://gitlab.com/...
- SSH URL: starts with
gi*@gi****.com:...
- HTTPS URL: starts with
๐ป Step 2: Clone the Repository
Open your terminal and run:
For HTTPS:
git clone https://gitlab.com/username/project-name.git
Git may prompt you for your GitLab username and password (or personal access token if 2FA is enabled).
For SSH:
git clone gi*@gi****.com:username/project-name.git
You must have your SSH key added to GitLab for SSH cloning to work.
๐ Step 3: Navigate into the Project
After cloning, move into the project folder:
cd project-name
You now have a complete local copy of the repository and are ready to code, build, or contribute.
๐ง Quick Summary
Action | Command/Step |
---|---|
Copy HTTPS/SSH URL | From GitLab โ Clone โ Copy URL |
Clone the project | git clone <URL> |
Move into project | cd project-name |
๐ Conclusion
Cloning a GitLab project is a foundational Git skill that allows you to contribute, explore, and collaborate. Whether using HTTPS or SSH, once you’ve cloned the repository, you’re ready to start coding locally.