AI Hints
Home›Git & GitHub Tutorial›Clone, Fetch and Pull
Git & GitHub · Lesson 59 of 144

Cloning a Repository

Git clone.

⏱ 2 min read▶ Video at 1:04:04🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

Cloning means downloading a full copy of a repository from GitHub, with its entire history. It's how you start working on an existing project, or how you get your own project onto a new computer.

Cloning a Repository
From the video: Cloning a Repository
  • Download a full copy
  • With the whole history
  • Start on any computer

git clone

We move to the projects folder, and type git clone, with the repository's address, and a folder name. Git creates the folder, and downloads everything into it. Inside, the log shows the full history. And the remote called origin is already set up for us.

git
cd ..
git clone https://github.com/sam/my-site.git laptop-copy
Cloning into 'laptop-copy'...
done.
cd laptop-copy
git log --oneline -n 3
f63a17a (HEAD -> main, origin/main, origin/HEAD) Link to about page
ef9c947 Add basic styles
6784119 Add about page
git remote -v
origin  https://github.com/sam/my-site.git (fetch)
origin  https://github.com/sam/my-site.git (push)

Clone, not download

GitHub also has a download zip button. But that gives you just the files, with no history, and no connection to GitHub. Cloning gives you a real repository, connected to origin, ready to pull and push. Without a folder name, clone simply uses the repository's name.

Download ZIPfiles only
git clonefull repository
Connectedorigin is set
No folder nameuses repo name

Summary

Git clone downloads a full repository, with history, and sets up origin for you. Next, keeping it up to date.

Key takeaways
  • git clone <url>
  • Full history
  • origin already set
Next up: Fetching Changes — git fetch