git clone Copy a remote repository onto your computer
Downloads a repository with its full history and sets up a link back to where it came from, named origin. It is the usual way to start work on an existing project.
Synopsis
git clone [OPTION]... URL [DIRECTORY]
Common options
| Option or form | What it does |
|---|---|
URL | The repository address, https or ssh, such as https://github.com/user/repo.git |
DIRECTORY | Folder to clone into. By default it is named after the repository |
-b NAME, --branch NAME | Check out that branch instead of the remote default |
--depth N | Shallow clone: fetch only the last N commits, which is faster for big repositories |
--recurse-submodules | Also fetch any submodules the project uses |
Examples
git clone https://github.com/octocat/Hello-World.git
git clone [email protected]:octocat/Hello-World.git hello
git clone -b develop --single-branch https://github.com/octocat/Hello-World.git
git clone --depth 1 https://github.com/octocat/Hello-World.git
Notes
- Cloning gives you a working copy, not just files. Every commit is local, so most later commands work offline.
- A shallow clone (--depth) cannot see old history. Run git fetch --unshallow to get the rest.
- With the GitHub CLI, gh repo clone owner/repo does the same job and works out the address for you.
See also
Last reviewed 2026-10-09.