Skip to main content

Git Remote

Updated 2 min read

Share this page

Send the link, quote the definition with a link back, or show it as a card on your own site.

https://softwaredictionary.org/terms/git-remote

In short

A Git remote is a named shortcut, such as origin, to another copy of your repository, usually on a server, that you push commits to and pull commits from.

What is a Git remote?

A Git remote is a bookmark your local repository keeps for another copy of the same project, usually hosted on a server or a code hosting platform. Each remote has a short name and a URL, so instead of typing the full address every time you can write git push origin main. It works like a contact in your phone: you save the name once and never type the full number again.

When you clone a repository, Git automatically adds a remote named origin that points to the URL you cloned from. You manage remotes with the git remote command: git remote -v lists them, git remote add creates one, and git remote set-url changes an address, for example when switching from HTTPS to SSH. The names and URLs are stored in the repository's .git/config file.

Remotes are how separate copies of a distributed repository stay in sync. After a git fetch, Git keeps read-only remote-tracking branches such as origin/main, which record where each branch was on the remote the last time you checked, so you can compare them with your local branches. A repository can have several remotes, and forked projects commonly use two: origin for your fork and upstream for the original project.

People often say 'the remote' to mean the remote repository itself, which is fine in conversation, but strictly the remote is only your local name and URL for it. Likewise, a remote-tracking branch such as origin/main is your local, possibly outdated, snapshot of a branch on that server, which is why git status can report 'up to date with origin/main' after teammates have already pushed new work. A remote is also different from a fork, which is a full copy of a repository on a hosting platform; your fork is simply one of the places a remote can point to.

Key takeaways

  • A remote is a short name, such as origin, paired with the URL of another copy of the repository.
  • git clone creates the origin remote automatically.
  • git remote -v lists remotes, and git remote add creates a new one.
  • Remote-tracking branches like origin/main show where the remote's branches were at the last fetch.
  • Forked projects often use origin for the fork and upstream for the original.

Example

Listing, adding, and changing remotesbash
# List remotes with their URLs
git remote -v
# origin  https://github.com/your-name/project.git (fetch)
# origin  https://github.com/your-name/project.git (push)

# Add the original project as a second remote
git remote add upstream https://github.com/original-owner/project.git

# Switch origin from HTTPS to SSH
git remote set-url origin git@github.com:your-name/project.git

# Download new commits from a remote and see what you're missing
git fetch upstream
git log --oneline main..upstream/main

Readers ask

What does origin mean in Git?

origin is the default name Git gives the remote you cloned from. It is only a convention, so you can rename it with git remote rename or add other remotes with different names.

What is the difference between origin and upstream?

origin usually points to your own copy of the repository, such as your fork, while upstream is the conventional name for the original project you forked from. Both are ordinary remotes; only the names differ.

How do I change a remote's URL?

Run git remote set-url <name> <new-url>, for example git remote set-url origin git@github.com:your-name/project.git. Check the result with git remote -v.

See also

Spotted a mistake or something missing on this page?Suggest an edit

Read a random page
Open today's review
Switch to the dark theme
Read this page in Türkçe

More

Settings