Clones & Remotes

Working with Remotes

Everything so far has lived only on your own machine. A remote is a copy of the repository hosted somewhere else - almost always a service like GitHub, GitLab, or Bitbucket - so that other people (and other machines, like a deployment server) can access the same project. origin is simply the conventional name Git gives to whichever remote you cloned from or added first; it's not a special keyword, just the default label.

CommandDoes
git clone <url>Download a copy of a repo, including its entire commit history
git remote -vList remotes and their URLs (-v = verbose)
git remote add origin <url>Link a local repo you made with git init to a remote
$ git clone https://github.com/user/project.git
Cloning into 'project'...
remote: Enumerating objects: 142, done.
Receiving objects: 100% (142/142), done.
$ cd project
$ git remote -v
origin  https://github.com/user/project.git (fetch)
origin  https://github.com/user/project.git (push)
Analogy: origin is like a shared Google Doc everyone contributes to. Your local repo is your own private copy of it, and you deliberately sync it up (push) and down (pull/fetch) with origin, rather than everyone typing into the same file simultaneously.
Note: Cloning downloads the entire history, not just the latest files - every commit anyone ever made. That's what makes Git distributed: your clone is a full, working backup of the project, not a thin snapshot. If the original server vanished today, any one clone could restore the whole thing.
Warning: Cloning fails with an authentication error more often than any other beginner Git problem, usually because of the URL style: an https:// URL will prompt for a username/password (or a personal access token, since GitHub no longer accepts plain passwords), while a git@github.com:... (SSH) URL requires an SSH key already set up on your account. Copying the wrong style of URL from GitHub's "Code" button for the auth method you've actually configured is the most common cause of "clone doesn't work" confusion.