🌱 BasicsCommonly used

How to clone a Git repository

Download a remote repository to your local machine.

Clone via HTTPS
git clone https://github.com/user/repo.git

Downloads the repository using HTTPS. You will be prompted for credentials when pushing.

When to use: Quick cloning without SSH setup. Easier for beginners.

Clone via SSH
git clone git@github.com:user/repo.git

Downloads the repository using SSH. Requires SSH key setup but no password prompts.

When to use: Recommended for daily use — no password prompts when pushing.

Clone into a specific folder
git clone https://github.com/user/repo.git my-folder

Clones the repository into a folder named "my-folder" instead of the repo name.

Clone a specific branch
git clone -b develop https://github.com/user/repo.git

Clones the repository and checks out the "develop" branch immediately.

Shallow clone (faster)
git clone --depth 1 https://github.com/user/repo.git

Clones only the latest commit, not the full history. Faster for large repos.

When to use: CI/CD pipelines or when you only need the latest code, not the full history.

← Back to Git Reference