Remotes are the bridges between your repository and everyone else's. origin appears the moment you clone; everything about collaboration — fetch, pull, push, and tracking branches — is the behaviour of this one concept.

The vocabulary #

Your repository keeps remote-tracking refs — local bookmarks of what the remote's branches were at the last contact:

The map of a clone
origin/main          <- your last-known state of their main (remote-tracking)
main                 <- your branch (may be ahead, behind, or diverged)
origin               <- the remote itself (a named URL)

git fetch updates the bookmarks; your branches never move. git pull is fetch plus integrate — the integrate step is a merge or a rebase depending on your config.

The daily commands #

The round trip of collaboration
$ git fetch origin                 # see what they did (safe, offline)
$ git log --oneline main..origin/main   # what's new there
$ git pull --rebase                # fetch + put my commits on top
$ git push                         # send my commits

Pushing an unpushed branch needs upstream wiring once — -u sets it and every later push is bare:

First push of a new branch
$ git push -u origin feature/toc
$ git push                          # now knows where to go

Managing remotes #

Add, rename, inspect, remove
$ git remote add upstream https://github.com/aospix/aospix-terminal.git
$ git remote -v                     # list with URLs
$ git remote rename origin og
$ git remote set-url origin git@github.com:aospix/aospix-terminal.git
$ git remote remove upstream

The classic two-remote setup is a fork: origin is your copy, upstream the real project — fetch from upstream, push to origin. Switching a remote from HTTPS to SSH (after setting up keys) is the set-url line.

Push, honestly #

CommandMeaning
git pushSend committed work to the tracking branch
git push --force-with-leaseRewrite remote history, safely
git push --tagsSend tags too
git push origin --delete feature/xRemove a remote branch

Push is the first operation that touches anything shared — which is why everything before it (commits, rebases, resets) is freely rewriteable and after it requires the golden rule.

Syncing many machines is clone and fetch discipline; the Git series continues.