CPCODELAB
Git & GitHub

Remotes and the Concept of origin

7 min read

What Is a Remote?

A remote is a version of your repository hosted somewhere else — usually GitHub. By convention, the primary remote is named origin. Remotes enable collaboration: you push your commits up and pull your teammates' commits down.

bash
git remote -v                                     # list remotes and their URLs
git remote add origin git@github.com:user/repo.git # add a remote
git remote rename origin upstream                  # rename a remote
git remote remove upstream                         # remove a remote

Remote Tracking Branches

When you fetch from a remote, Git creates remote-tracking branches like origin/main. These are read-only snapshots of what the remote looked like the last time you communicated with it. Your local main and origin/main are separate pointers.

You will often see origin/main referred to in error messages. It is not a branch you switch to — it is a reference point that updates when you git fetch.

Ready to test yourself?
Practice Git & GitHub— quiz & coding exercises