git clone
Clones an existing repository into a new directory.
Syntax
git clone <repository> [<directory>]
Options
- repository: Required. URL or path of the repository to clone
- directory: Optional. Name of the new directory to clone into
- --depth <depth>: Creates a shallow clone with the specified number of commits
- --branch <name>: Clones a specific branch instead of the default
- --single-branch: Clones only the history of a single branch
- --recurse-submodules: Initializes and clones submodules
Example
git clone https://github.com/user/repo.git my-local-copy
Tip
Use --depth 1 for a fast shallow clone when you don't need full history.