Remotes and GitHub

Clone a repository

Download a remote repository, its branches, and its history into a new local folder.

Cloning creates a new local repository from an existing one. You get the full history, not just the latest files.

That matters when you need to inspect old commits, bisect a bug, or work offline. A normal clone copies every reachable object the remote offers.

From your projects folder, clone the course’s notes-project repository over SSH:

git clone [email protected]:flaviocopes/notes-project.git

Git creates a notes-project folder, copies reachable repository data, configures the source as origin, and checks out the remote’s default branch as a local branch.

Move into the repository and inspect the state:

cd notes-project
git status
git remote -v
git branch --all
git log --oneline -3

git status should report a clean working tree on main. git branch --all might show * main plus remotes/origin/add-search without creating a local add-search branch for you.

A clone is independent. New local commits do not change the source repository until you push and have permission to do so.

Wrong URL scheme is a common failure. HTTPS and SSH URLs look similar but authenticate differently:

git clone https://github.com/flaviocopes/notes-project.git

That works too, but later lessons assume SSH remotes like [email protected]:.... Mixing schemes across machines causes confusing credential prompts. Pick one scheme per clone and stick with it.

Another failure: cloning into a folder that already exists. Git refuses with fatal: destination path 'notes-project' already exists. Remove or rename the old folder, or clone into a new directory name.

If cloning stops midway, remove only the incomplete destination folder after confirming its exact path, then retry. Do not run git init inside the partial clone and hope it repairs missing objects.

Try this: clone notes-project, disconnect from the network, and run git log. The history stays on your disk because the clone copied the objects locally.

Lesson completed