Git clone: clone a remote repository
Want to join an existing project? git clone copies a remote repository to your computer with its full history. Learn how to use it and its most useful options.
What is git clone?
git clone creates a complete copy of a remote repository on your computer. It downloads all files, all commits, all branches, and all tags.
It's the command you use to join an existing project hosted on GitHub, GitLab, or any other Git server.
After cloning, you have a complete and independent local repository. You can commit, create branches, and work offline.
Git clone syntax
git clone <url>Clones into a folder with the same name as the repository
git clone <url> <folder>Clones into a custom-named folder
git clone --depth 1 <url>Shallow clone (without history)
git clone --branch <branch> <url>Clone a specific branch
Git clone in practice
Basic clone and advanced options.
Standard clone
Useful options
HTTPS vs SSH: which URL to use?
HTTPS
https://github.com/user/repo.git- ✓ Easy to set up
- ✓ Works everywhere (firewall, proxy)
- ✗ Asks for credentials on each push
SSH
git@github.com:user/repo.git- ✓ No need to re-enter credentials
- ✓ More secure (cryptographic key)
- ✗ Initial setup required
Part of the Git Remote & Collaboration guide
GitQuest is created by Anaïs (nouvelle fenêtre), web developer and head of education, specializing in tech training and digital accessibility.
Questions about git clone
Practice cloning in GitQuest
GitQuest investigations put you face to face with repositories to clone and explore in a secure terminal.
Start the investigations