Skip to the workspace
Pebellslearn by building
Git Remotes  ›  Lesson

Managing Remotes

Managing Remotes 12 minA remote is a local nickname for another copy's URL, managed with git remote add, -v, rename, set-url and remove, and it produces remote-tracking branches such as origin/main.

git github / Managing Remotes

Explore each scene at your own pace.

01 · The rule

The rule

Managing Remotes

A remote is just a saved nickname for another copy of the repository, usually on a server. Ravi's clone got one automatically. Asha started with git init, so her repository knows about no remotes until she adds one. Either way, a handful of commands manage the list.

The rule

A remote is a nickname for a URL; add, list, rename, re-point or remove it.

git remote -v                                    # list remotes and their URLs
git remote add origin https://github.com/asha-dev/recipe-box.git
git remote set-url origin git@github.com:asha-dev/recipe-box.git   # new URL
git remote rename origin github                  # change the nickname
git remote remove github                         # forget a remote

Key facts:

  • origin is only a convention. It is the name Git gives the place you cloned from, and the name most people choose when adding their main remote. Nothing about it is special.
  • A repository can have many remotes. When you contribute to someone else's project, it is common to have origin for your own copy and upstream for the original.
  • Removing a remote deletes nothing on the server. It only removes the nickname, and the remote-tracking branches, from your local repository.
  • git remote -v shows two lines per remote, one marked (fetch) and one (push). They are normally the same URL.

Remotes also create remote-tracking branches such as origin/main. These are your repository's memory of where each branch was on the remote the last time you talked to it. They update only when you fetch, pull or push, never on their own.

Inspect one remote in detail with:

git remote show origin

It lists the remote's branches and which of your local branches push to and pull from them.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.