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
[email protected]:...
- 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 [email protected]: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.