Files
mintlify__docs/git/clone.mdx
2026-02-09 20:46:44 +00:00

99 lines
2.1 KiB
Plaintext

---
title: git clone
description: Clone a repository into a new directory
---
Clone an existing Git repository to your local machine.
## Syntax
```bash
git clone [options] <repository> [directory]
```
## Description
`git clone` creates a copy of an existing repository, including all files, branches, and commit history. It automatically sets up a remote connection to the original repository.
## Common usage
Clone a repository:
```bash
git clone https://github.com/username/repository.git
```
Clone into a specific directory:
```bash
git clone https://github.com/username/repository.git my-folder
```
## Options
<ParamField path="--branch" type="string">
Clone a specific branch instead of the default
```bash
git clone --branch develop https://github.com/username/repo.git
```
</ParamField>
<ParamField path="--depth" type="number">
Create a shallow clone with limited history
```bash
git clone --depth 1 https://github.com/username/repo.git
```
</ParamField>
<ParamField path="--single-branch" type="flag">
Clone only one branch, reducing download size
</ParamField>
<ParamField path="--recurse-submodules" type="flag">
Initialize and clone submodules automatically
</ParamField>
## Examples
### Clone via HTTPS
```bash
git clone https://github.com/username/repository.git
```
### Clone via SSH
```bash
git clone git@github.com:username/repository.git
```
### Shallow clone for faster downloads
```bash
git clone --depth 1 https://github.com/username/large-repo.git
```
### Clone a specific branch
```bash
git clone --branch feature-x --single-branch https://github.com/username/repo.git
```
## What happens after clone?
After cloning, you have:
- A complete local copy of the repository
- All branches (fetch with `git fetch` to see them)
- A remote named `origin` pointing to the source repository
- The default branch checked out and ready to work with
## Related commands
- [git init](/git/init) - Create a new repository
- [git fetch](/git/fetch) - Download updates from remote
- [git pull](/git/pull) - Fetch and merge changes
- [git remote](/git/remote) - Manage remote connections