Skip to main content

What is `remote` in Git?

Remote (a remote repository) in Git is a link to an external Git repository, saved in Git's configuration, with which your local repository can exchange commits.

In simpler terms: a remote is a name + URL of the remote repository, by which Git knows where to send (push) and where to fetch (fetch/pull) changes from.


What a remote is from Git's point of view

A remote is not the repository itself, but a record in Git's configuration, which contains:

  • a name (for example, origin)
  • a URL (an HTTPS or SSH address of the repository)

Git can have several remotes, each pointing to its own repository.


Why a remote is needed

A remote is used for:

  • syncing the local repository with a server
  • collaboration between multiple developers
  • publishing your changes
  • getting changes from others
  • keeping a backup copy of the project

Without a remote, Git stays fully local.


origin is not a special word

origin is the default remote name that Git creates on git clone.

Important:

  • origin is just a name
  • it can be removed, renamed, or other remotes can be added
  • Git does not require a remote to be named origin

Viewing remotes

bash
git remote
bash
git remote -v

Shows the remote names and their URLs.


Adding a remote

bash
git remote add origin https://github.com/user/repo.git

Removing a remote

bash
git remote remove origin

Renaming a remote

bash
git remote rename origin upstream

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.