Back
GitoryxGitoryx
Beginner8 min read

Git Clone: How to Copy a Repository

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.

bash
git clone git@github.com:user/my-project.git frontend
4

Clone a specific branch

By default, you get the default branch (usually `main` or `master`). Use `-b` to start on a specific branch.

bash
git clone -b develop git@github.com:user/my-project.git
See this workflow in Gitoryx — Gitoryx screenshot

See this workflow in Gitoryx. Paste any HTTPS or SSH URL and clone with one click

Free download
5

Shallow clone for large repositories

If the repository has a very long history and you just need the latest code, `--depth 1` clones only the most recent commit.

bash
git clone --depth 1 git@github.com:user/large-repo.git

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.

bash
cd my-project
git remote -v

# origin  git@github.com:user/my-project.git (fetch)
# origin  git@github.com:user/my-project.git (push)

Common Mistakes to Avoid

Cloning into a non-empty folder

Git refuses to clone into a folder that already contains files.

Fix: Create a new empty folder first, or let Git create it automatically by not passing a destination path.

Using HTTPS and entering credentials on every push

Without a credential helper or SSH keys, Git asks for your username and password each time.

Fix: Set up SSH keys and use the SSH clone URL, or configure Git Credential Manager.

Cloning instead of forking a project you want to contribute to

If you don't have write access to the repo, you need to fork it first, then clone your fork.

Fix: Fork the project on GitHub/GitLab, then clone your own fork.

Gitoryx — visual Git client for macOS, Windows & Linux
GitoryxGitoryx — macOS, Windows & Linux

Clone repositories visually with Gitoryx

  • Paste any HTTPS or SSH URL and clone with one click
  • Gitoryx detects and configures SSH keys automatically
  • The repository opens in the visual graph immediately after cloning
  • Switch branches and inspect history right after clone — no CLI needed
Download Gitoryx — FreemacOS · Windows · Linux · No subscription

Frequently Asked Questions

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.

See it in action with Gitoryx

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.