Git Clone
Git Clone: Downloading Existing Repositories Locally
git clone downloads an entire remote repository—including its files, commit history, branches, and remote origin configuration—into a new folder on your computer. Unlike downloading a ZIP archive from GitHub, cloning gives you a live .git workspace ready for commits and pushes.
Standard Cloning with SSH or HTTPS
Copy the repository address from GitHub and run git clone:
git clone git@github.com:your-username/starter-site.git
cd starter-site
By default, git clone creates a directory matching the repository name (starter-site), sets up origin, checks out the default branch (main), and preserves full commit history.
Cloning into a Custom Folder or Specific Branch
Pass a second argument to choose a different local folder name, or pass -b to check out a specific release branch or tag immediately:
git clone git@github.com:your-username/starter-site.git my-portfolio
git clone -b feature/header-nav git@github.com:your-username/starter-site.git
Shallow Clones (--depth 1) for Faster CI/CD
Large repositories with ten years of commits can take minutes to download. When a build server or quick inspection only needs the latest snapshot without full history, use a shallow clone:
git clone --depth 1 git@github.com:your-username/starter-site.git
--depth 1 fetches only the most recent commit on the default branch, dramatically reducing download size and clone time.
Common Cloning Mistakes
Running git clone while already inside another Git repository folder creates a nested .git directory that confuses parent git status checks. Always navigate to a dedicated projects folder such as ~/projects before cloning.
Also verify whether the project contains submodules; if it does, clone with git clone --recurse-submodules <url> so nested libraries are populated too.
Frequently Asked Questions
What is the difference between git clone and git pull?
git clone is run once to download a brand-new local copy of a remote repository. git pull is run inside an already-cloned repository to fetch and integrate newer commits.
Can I turn a shallow clone into a full clone later?
Yes. Run git fetch --unshallow inside the cloned folder to download the rest of the commit history.
Why does git clone ask for a username and password on HTTPS URLs?
GitHub no longer accepts account passwords over HTTPS Git. Either switch to an SSH clone URL (git@github.com:...) or use a Personal Access Token / GitHub CLI (gh auth login).
Unlock Your
Full Potential.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With