Remotes Explained
A Git remote is simply a bookmark, stored in your repository's config, that maps a short name to a repository URL — most commonly origin, pointing at the copy of the project hosted on GitHub, GitLab, or a similar service. Because Git is distributed, every clone is a full repository in its own right, containing the entire history; remotes exist purely so your local repository knows which other repositories to talk to and how to reach them, without those other repositories needing to know anything about you until you push. A repository can have zero, one, or many remotes — a common multi-remote setup is having origin for your fork and upstream for the original project you forked from.
Cricket analogy: A remote is like a franchise keeping a contact card labeled 'BCCI' pointing to the central board's office — every franchise runs its own operations fully independently, and the contact card just tells them where to send match reports, nothing more until they actually make contact.
Managing Remote Configuration
git remote -v lists configured remotes and their URLs for both fetch and push (which can differ, though usually don't). git remote add <name> <url> registers a new remote, git remote remove <name> deletes one, and git remote rename <old> <new> renames one. git remote set-url <name> <url> changes an existing remote's URL — needed, for example, when a repository moves or when you switch from HTTPS to SSH authentication for that remote. None of these commands transfer any data; they only edit the local .git/config mapping of names to URLs.
Cricket analogy: This is like a franchise's admin office maintaining a directory of contact addresses for the board, sponsors, and broadcasters — adding, removing, or renaming an entry in that directory is just paperwork and never actually sends a message to anyone until someone picks up the phone.
Remote-Tracking Branches
When you clone or fetch, Git stores a local, read-only copy of each branch on the remote under a namespaced ref like origin/main — these are called remote-tracking branches, and they represent the state of the remote's branches as of your last fetch, not live, constantly-updating mirrors. git branch -r lists them; git branch -vv shows which local branches are tracking which remote-tracking branches. Because remote-tracking branches are only updated by explicit fetch, pull, or push operations, it's normal (and expected) for origin/main in your local repo to lag behind the actual main on the server until you fetch again.
Cricket analogy: This is like a franchise keeping a snapshot of a rival team's roster from the last transfer window — it shows the rival's squad as of that last check, not a live feed, so it's expected to lag until the franchise's scouts actively refresh their intelligence report again.
# List remotes with their URLs
git remote -v
# origin git@github.com:acme/webapp.git (fetch)
# origin git@github.com:acme/webapp.git (push)
# Add a second remote pointing at the original project you forked from
git remote add upstream https://github.com/original-org/webapp.git
# Fetch from a specific remote without merging
git fetch upstream
# Change an existing remote's URL, e.g. switching to SSH
git remote set-url origin git@github.com:acme/webapp.git
# Inspect a remote in detail: URL, tracked branches, HEAD branch
git remote show origin
# Remove a remote you no longer need
git remote remove old-mirrorThere's nothing magical about the name origin — it's just the conventional default name Git assigns when you clone a repository. You could rename it, or have a repository with remotes named origin, upstream, staging, and backup-server simultaneously; Git treats them all identically as named URLs to fetch from and push to.
git remote remove <name> deletes the local remote-tracking branches associated with that remote and forgets its URL, but it does NOT delete anything on the actual remote server — the hosted repository and its branches are untouched. Conversely, be careful with git push <remote> --delete <branch>, which does delete a branch on the actual server for everyone.
- A remote is a named URL, stored in local config, pointing at another copy of the repository — commonly
origin. git remote -v/add/remove/rename/set-urlmanage remote configuration without transferring any data.- A repository can have multiple remotes at once, e.g.
origin(your fork) andupstream(the source project). - Remote-tracking branches like
origin/mainare local snapshots of the remote's branches as of the last fetch, not live mirrors. - Only explicit
fetch,pull, orpushoperations update remote-tracking branches or transfer data. - Removing a remote only affects your local config and tracking refs — it never deletes anything on the actual server.
Practice what you learned
1. What is a Git 'remote' fundamentally?
2. What does `origin/main` represent in your local repository?
3. In a typical fork-based contribution workflow, what does the `upstream` remote usually point to?
4. Does `git remote remove upstream` delete the `upstream` repository on the hosting server?
5. Which command changes the URL of an already-configured remote (e.g. switching from HTTPS to SSH)?
Was this page helpful?
You May Also Like
Push, Pull, and Fetch
Push, pull, and fetch are the three commands that move commits between your local repository and a remote — understanding exactly what each does (and doesn't do) prevents most everyday Git confusion.
Tracking Branches
A tracking branch is a local branch configured with a direct relationship to a remote branch, enabling short commands like plain `git push` or `git pull` and clear ahead/behind status.
Forking and Cloning
Cloning creates a full local copy of a repository's history, while forking creates a server-side copy under your own account — together they underpin how most open-source contribution happens.
Pull Requests and Code Review
How pull requests turn a branch into a reviewable, discussable proposal for merging code, and the practices that make code review effective rather than a rubber stamp.
Related Reading
Related Study Notes in Software Engineering
Browse all study notesMicroservices Study Notes
Software Architecture · 30 topics
Software EngineeringTesting & TDD Study Notes
Software Testing · 30 topics
Software EngineeringDesign Patterns Study Notes
Software Design · 30 topics
Software EngineeringSoftware Engineering Study Notes
Python · 40 topics
Software EngineeringSystem Design Study Notes
Architecture · 40 topics