Clone an existing project to a new computer

safe beginner #clone#new pc

When to use this: The project is already on GitHub and you want a working copy on this PC.

Before you start

Steps

  1. Go to the parent folder

    PowerShellGit Bash
    cd C:\Users\Asanka\Documents\GITcd /c/Users/Asanka/Documents/GIT

    Clone creates a new sub-folder here, so do not run it inside another repo.

  2. Clone

    terminal
    git clone https://github.com/YOUR-USER/YOUR-REPO.git

    Downloads the whole history and sets origin automatically. Copy the URL from the green 'Code' button on GitHub.

  3. Enter the folder and install dependencies

    terminal
    cd YOUR-REPO
    npm install

    Dependencies and .env files are not in Git. Reinstall packages, and recreate secrets (for Vercel projects: vercel env pull .env.local).

How to verify it worked

  • git status shows a clean tree on main, and git remote -v shows your repo.

How to undo it

Just delete the cloned folder. Nothing on GitHub changes.

PowerShellGit Bash
Remove-Item -Recurse -Force .\YOUR-REPOrm -rf ./YOUR-REPO

Common errors and fixes

destination path already exists and is not an empty directory A folder with that name exists. Clone into another name: git clone <url> new-name.
Repository not found Wrong URL, or a private repo and you are signed in to the wrong GitHub account. Check gh auth status.

Q&A

Does clone also copy my branches?

It downloads all remote branches but only checks out the default one. Others appear as origin/<name>; git switch <name> creates a local copy.

Practice these as flashcards →

Terms in this scenario

Related scenarios

My notes

Saved in this browser only.