All commands

git remote

Manage the bookmarks that point at other repositories.

What it does

git remote is a thin config manager: it lists, adds, renames and removes remote bookmarks. Each remote is just a name → URL mapping stored in .git/config. The commands git fetch, pull and push all read that mapping when you say 'origin'.

Your machine

local repository

main
everything streams down ↓

Remote origin

everything.git

refs/heads/main

git remote wires origin in the config — the bookmark for the outside world

Watch it — press play

A narrated, step-by-step walkthrough that shows how to do it — not just theory. It adapts to the learner mode you picked in the top bar.

1 / 2

Step 1

Bookmark another repo

A remote is just a name → URL note. No network happens until you fetch or push.

git remote add origin git@github.com:user/repo.git

Your machine

local repository

main
everything streams down ↓

Remote origin

everything.git

refs/heads/main

git remote add links a name to a URL

Under the hood

1

A remote is two lines of config

git remote add origin <url> writes a section into .git/config. Nothing is transferred, no network happens — it's a bookmark.

[remote "origin"]
  url = git@github.com:user/repo.git
  fetch = +refs/heads/*:refs/remotes/origin/*
2

Fetch lines become remote-tracking refs

The fetch refspec says 'take remote heads and store them locally under refs/remotes/origin/'. That's why `git fetch` later creates local read-only copies of every remote branch.

Aliases the pros type

Memorize the git remote concept, then let one of these shortcuts make it instant. Aliases are real git config keys — add one with:

git config --global alias.st # → git remote
AliasWhy people use it
g rm

List remote bookmarks.

g rmv

List WITH their URLs — the honest view.

g rma

The fork-flow standard: add upstream.

Command anatomy

git remote add <name> <url>
add

Bookmark a new repository.

-v

List remotes with their fetch/push URLs.

remove

Delete a bookmark (doesn't touch the remote repo).

rename

Change a remote's name.

set-url

Repoint a remote's URL (e.g. HTTPS → SSH).

When to reach for it

Forking workflow: add an upstream remote pointing at the original repo.

Switching from HTTPS to SSH auth: git remote set-url origin git@….

Checking where 'origin' actually lives before pushing somewhere sensitive.

Pro tip

The fork workflow lives on remotes: `origin` = yours, `upstream` = the original. Keep both, fetch upstream, merge upstream/main into your feature, and the project's maintainers can merge your PR cleanly.

Go deeper with