Git clone Command
In this page:
What is git clone?
git clone <url> downloads a complete copy of a remote repository -- every commit, every branch, the full history -- onto your machine in one step, giving you a fully independent local repository ready to work in immediately.
Example: What is git clone?
git clone https://github.com/user/repo.git
Cloning from a Remote URL
Cloning works over HTTPS or SSH URLs, and either way Git automatically creates a remote connection named origin pointing back to that source, so future push and pull commands know exactly where to sync.
Example: Cloning from a Remote URL
git clone https://github.com/user/repo.git
git remote -v
Cloning into a Specific Folder
By default the cloned folder is named after the repository itself, but git clone <url> <folder-name> lets you clone into a custom directory name -- useful when you already have a folder with that name, or want something more descriptive.
Example: Cloning into a Specific Folder
git clone https://github.com/user/repo.git my-folder
Cloning a Specific Branch
Cloning normally checks out only the default branch, but git clone --branch <name> <url> lets you clone and check out a specific branch directly, skipping the extra step of switching branches after the fact.
Example: Cloning a Specific Branch
git clone --branch develop https://github.com/user/repo.git
Checking the Cloned Remote
Running git remote -v right after a clone shows you the origin URL Git configured automatically -- a quick sanity check that you're pointed at the repository you actually intended to clone.
Example: Checking the Cloned Remote
git remote -v
Chapter Quiz — Complete all 18 topics to unlock
0/18 topics done
Complete these topics first:
- Git init Command
- Git New Files
- Git Staging Environment
- Git clone Command
- Git status Command
- Git help Command
- Git add Command
- Git commit Command
- Git tags Command
- Git stash Command
- Git log Command
- Git diff Command
- Git show Command
- Git rm Command
- Git mv Command
- Git restore Command
- Git clean Command
- Git ignore (.gitignore)