git clone Explained: Copy a Repository to Your Computer
git clone downloads a full copy of a repository, history and all. How to clone with HTTPS or SSH, clone into a specific folder or branch, shallow clones for big repos, private repositories and authentication, and what to do right after cloning.
git clone makes a complete copy of a Git repository on your computer — every file, every commit in its history, and every branch. It's usually the first Git command you run on a project. (Git and GitHub for beginners)
The basic command
On GitHub, click the green Code button and copy the URL. Then:
git clone https://github.com/vercel/next.js.git
This creates a folder called next.js with the project inside, and sets up a connection called origin pointing back to where you cloned from. (git remote add origin)
cd next.js
HTTPS or SSH?
GitHub offers two kinds of URL:
git clone https://github.com/you/app.git # HTTPS
git clone git@github.com:you/app.git # SSH
- HTTPS works everywhere and needs no setup for public repos. For private repos or pushing, you'll authenticate with a browser login (via Git Credential Manager or
gh auth login) or a personal access token — not your GitHub password, which GitHub stopped accepting for Git years ago. - SSH uses a key on your computer. Set it up once and you never type credentials again. (SSH keys explained)
If you get Permission denied (publickey) with an SSH URL, your key isn't set up or added to GitHub. (Fix it)
Useful options
Clone into a folder with a different name:
git clone https://github.com/you/app.git my-app
git clone https://github.com/you/app.git . # into the current (empty) folder
Clone and check out a specific branch:
git clone --branch develop https://github.com/you/app.git
Shallow clone — only recent history (faster for big repos):
git clone --depth 1 https://github.com/you/app.git
Great for CI or when you just need the code. You can fetch more history later with git fetch --unshallow.
Include submodules:
git clone --recurse-submodules https://github.com/you/app.git
What to do right after cloning
Cloning gets the code, not a working app. Typically:
- Read the README for setup steps. (How to write a README)
- Install dependencies —
npm install,pip install -r requirements.txt, etc. (requirements.txt explained) - Create your
.env— copy.env.exampleto.envand fill in values. Secrets aren't in the repository (or shouldn't be). (Environment variables explained) - Set up the database if there is one — run migrations, maybe seed data. (Database seeding)
- Run it — often
npm run dev. (npm run dev vs build)
If it fails, the README is incomplete — a good first contribution is to fix it.
Clone vs download ZIP
GitHub's Download ZIP gives you the files but no Git history and no connection to the original. You can't pull updates or push changes. Use clone unless you really just want a snapshot.
Clone vs fork
Cloning copies a repo to your computer. Forking copies it to your GitHub account — needed when you want to contribute to someone else's project. You often fork first, then clone your fork. (Fork vs clone)
Common errors
fatal: destination path 'app' already exists and is not an empty directory— a folder with that name exists. Choose another name or delete it.Repository not found— wrong URL, or a private repo you don't have access to (or aren't logged in for).Filename too longon Windows — rungit config --global core.longpaths true.- Line-ending warnings on Windows. (LF will be replaced by CRLF)
EasySpawn clones your repository onto a persistent server with dependencies installed and the app running, so "works on my machine" setup takes minutes, not an afternoon. See how it works or join the waitlist.
Related: Git and GitHub for Beginners · Fork vs Clone · SSH Keys Explained · git fetch vs git pull
Keep reading
What Is WSL? Running Linux on Windows, Explained
WSL lets you run a real Linux system inside Windows without dual-booting or a separate virtual machine to manage. What it is, why web developers use it, how to install it, where your files live, and the performance and networking gotchas.
What Is OpenAI Codex? The Coding Agent Explained
Codex is OpenAI's coding agent: a desktop app, a command-line tool, IDE extensions and cloud tasks that read your code, make changes and run commands. What it does, how it differs from the old 2021 Codex model, what it costs with ChatGPT plans, and how it compares with Claude Code.