World map

 

BM: Baca dalam Bahasa Melayu

World 4: Hello GitHub

Clone a project

You will learn: how to copy a whole project from GitHub to your computer.

The problem

Your laptop broke. The new one is empty. Luckily, your diary is safe on GitHub. How do you get it back?

Pick one answer.

Watch

git clone makes a diary folder. Inside, git log shows all three commits, with origin/main next to main. Terminal output: $ git clone https://github.com/you/diary.git Cloning into 'diary'... $ cd diary $ git log --oneline ea2c020 (HEAD -> main, origin/main, origin/HEAD) Add purple style f6c78e5 Add home page 2efd0f2 Add README

clone: Copy a whole project to your computer. copies the whole project: every file and every commit. It even saves the address as origin for you.

Try it

Clone your diary onto the new laptop. Then step into its folder.

Predict

You just cloned. Which remotes does the new repo have?

Pick one answer.

Check

Tap every line about GitHub's copy.

~ $ git clone https://github.com/you/diary.git~ $ cd diary~/diary $ git branch -a

0 of 2 found

Check

What comes with a clone? Sort each one.

Drag a card into a box. Or tap the card, then tap the box.

      You did it!

      You can now clone any project from GitHub.

      Go deeper (optional)

      git clone <url> my-diary picks the folder name. With an SSH key, clone the SSH address instead. Cloning someone else’s public repo works too. To change it, you’ll need a fork (lesson 12).