git clone is how you download a repository to your local machine. This tutorial explains the different cloning methods, options like depth and branch selection, and how to handle common issues.
The Problem
You want to work on a project hosted on GitHub or GitLab. You could download the ZIP — but then you'd lose all Git history and collaboration features. The right tool is `git clone`.
Cloning is how every developer gets a local copy of a remote repository. It downloads the full history, sets up the remote origin automatically, and puts you ready to commit, push, and collaborate immediately.
Common mistakes developers make with this:
Using HTTPS instead of SSH and being prompted for a password on every push
Cloning into the wrong directory or an already-existing folder
Forgetting to clone before trying to `git pull` (you can't pull what doesn't exist locally)
Cloning a repo with a very large history and waiting minutes for it to complete
Gitoryx: Gitoryx lets you clone any repository by pasting a URL — it handles HTTPS and SSH automatically and opens the repo in the visual interface as soon as the clone completes.
What is Clone: How to Copy a Repository?
`git clone` creates a local copy of a remote repository, including its full history, branches, and tags. It automatically creates a remote called `origin` pointing back to the source.
Step-by-Step Guide
1
Copy the repository URL
On GitHub, GitLab, or Bitbucket, click the 'Code' or 'Clone' button and copy the URL. You'll see two options: HTTPS and SSH.
Use SSH if you've set up SSH keys — you'll never be prompted for a password. Use HTTPS for a quick start without SSH setup.
2
Clone the repository
Run `git clone <url>` in the terminal. Git creates a new folder with the repository name and downloads everything inside.
bash
# Clone via HTTPS
git clone https://github.com/user/my-project.git
# Clone via SSH
git clone git@github.com:user/my-project.git
3
Clone into a custom folder name
By default, Git names the folder after the repo. Pass a second argument to use a different name.
Shallow clones lack full history. Commands like `git log`, `git bisect`, and `git blame` will be limited. Don't use `--depth 1` if you plan to contribute back.
6
Verify the clone
After cloning, enter the folder and check the remote is set correctly.
What is the difference between `git clone` and `git pull`?
`git clone` creates a brand new local copy of a remote repository from scratch. `git pull` updates an existing local repository with new changes from the remote. You clone once; you pull many times.
Can I clone a private repository?
Yes, as long as you have access. Use SSH keys or HTTPS with your credentials. On GitHub you can also use a personal access token in place of a password.
Does `git clone` download all branches?
Yes, all remote branches are fetched, but only the default branch is checked out locally. Use `git checkout -b <branch> origin/<branch>` to switch to another branch after cloning.
How do I clone only one branch?
Use `git clone -b <branch-name> <url>`. This checks out the specified branch, though the other remote branches are still available.
Everything in this tutorial is faster and clearer with a visual Git client. Gitoryx is free, runs natively on macOS, Windows, and Linux, and built for developers who want to move fast without breaking things.