Clone a Git Repository with git clone
Copy a remote repository — code plus full history — into a new local folder in one command.
01Command
$ git clone https://github.com/example/project.git && cd project02What it does
git clone fetches every branch and commit by default and sets up 'origin' as the remote, so pull/push work immediately. On slow connections or huge repos, --depth 1 fetches only the latest commit (shallow clone) and --recurse-submodules also pulls nested repositories; --branch lets you check out a non-default branch straight away. SSH URLs (git@github.com:user/repo.git) authenticate with your key instead of a token.
03Risk
04Undo
$ rm -rf project05Sources
- git-clone — Clone a repository into a new directoryEvidence: Official docs describe cloning into a new directory, HTTPS/SSH URLs, and options --depth, --branch and --recurse-submodules; confirms 'git clone' and '--depth' appear in the text.
- git-clone(1) — Debian man pageEvidence: Man page documents 'git clone' usage with repository URL argument and the --depth option for shallow clones.
Last verified: 2026-09-19 · Category: Developer
06Related solutions
Find every occurrence of a pattern across all files in a tree, printed as file:line:number matches.
Generate a modern Ed25519 public/private key pair in ~/.ssh for authenticating to servers and Git platforms without passwords.
Send a HEAD request to any URL and print the status line, server, content type, caching, and redirect headers.