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
-
Go to the parent folder
PowerShellGit Bashcd C:\Users\Asanka\Documents\GITcd /c/Users/Asanka/Documents/GITClone creates a new sub-folder here, so do not run it inside another repo.
-
Clone
terminalgit clone https://github.com/YOUR-USER/YOUR-REPO.gitDownloads the whole history and sets
originautomatically. Copy the URL from the green 'Code' button on GitHub. -
Enter the folder and install dependencies
terminalcd YOUR-REPO npm installDependencies and
.envfiles are not in Git. Reinstall packages, and recreate secrets (for Vercel projects:vercel env pull .env.local).
How to verify it worked
git statusshows a clean tree onmain, andgit remote -vshows 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.