Skip to main content
Back to command reference
Getting Started

git clone

Copy an existing repository to your local machine

Practical example

bash
git clone https://github.com/user/repo.git
cd repo
git remote -v  # shows 'origin' -> https://github.com/user/repo.git

Command overview & how it works

Downloads the entire repository history and all files from a remote URL, creating a local working directory with the remote automatically configured as 'origin'. The command supports multiple transport protocols: HTTPS (git clone https://github.com/user/repo.git), SSH (git clone git@github.com:user/repo.git), and the Git protocol. Use --depth=1 for a shallow clone that downloads only the latest commit — useful for CI pipelines or large repositories where full history is unnecessary. Use --recurse-submodules to also clone any submodules. Use --branch to clone a specific branch instead of the default HEAD.

Chapter 01 · Mental Model & Architecture

Get the complete offline Git Field Guide

The 97-page PDF + ePub course — ₹499. Read this command, offline.

Learn more

Practical tips

  • Add --depth=1 for a shallow clone when you only need the latest snapshot, such as in a CI pipeline.
  • After cloning, verify the remote with git remote -v — the origin remote is configured automatically.
  • Use --branch to clone a specific branch, and --recurse-submodules when the project relies on submodules.

Deep-dive guides & tutorials

In-depth walkthroughs and practical scenarios related to git clone

All guides →
  • Guide

    How to Install Git on Windows, macOS, and Linux

    A step-by-step setup guide covering every major platform, from Homebrew and Winget to package managers, plus verifying your install and configuring your identity.

    7 min readRead guide
  • Tutorial

    Git Basics Every Developer Should Know

    Understand the core concepts — repositories, commits, branches, and remotes — before diving into the command line.

    6 min readRead guide
  • Guide

    How to Write Better Git Commit Messages

    A practical guide to writing clear, conventional commit messages that make your project history readable and your team more productive.

    6 min readRead guide

Related commands

More from Getting Started