Git 2 reference · Remotes
git clone Command (Git)
Copy a repository with its full history and set up origin as the remote; --depth makes a shallow copy.
Git 2
Syntax
git clone [--depth N] [-b BRANCH] URL [DIRECTORY]
Parameters
| Parameter | Description |
|---|---|
--depth N |
Only the last N commits (faster CI checkouts). |
-b BRANCH |
Check out a specific branch. |
--filter=blob:none |
Partial clone: fetch file contents on demand. |
Examples
git init -q -b main app && cd app
echo '# Shop' > README.md
git add README.md && git commit -q -m 'Initial commit'
cd ..
git clone -q app app-copy
git -C app-copy log --oneline
git -C app-copy remote -v | head -1
Output
7f7f133 Initial commit origin /tmp/tmpa2oy2arj/app (fetch)
Run this on your computer — see “Get Started” for setup.
git init -q -b main app && cd app
echo '# Shop' > README.md
git add README.md && git commit -q -m 'Initial commit'
for i in 1 2 3; do echo $i > n; git add n; git commit -q -m "c$i"; done; cd ..
git clone -q --depth 1 file://$PWD/app shallow
git -C shallow log --oneline
Output
904a32e c3
Run this on your computer — see “Get Started” for setup.
Related
git remote· List, add, rename and remove the remote repositories a local repository talks to.git fetch and git pull· Download new commits from a remote (fetch), or download and integrate them into your branch (pull).git push· Upload local commits and tags to a remote branch; -u sets the upstream, and --force-with-lease rewrites history safely.- Remotes: clone, fetch, pull and push · tutorial