Git commands

git remote

git remote: manage remote repositories.

The git remote command is used to manage connections to remote repositories. A remote in Git is a reference to a repository that exists somewhere else, typically on a remote server like GitHub, GitLab, or Bitbucket. Remotes allow you to collaborate with others by pushing your changes to and pulling changes from shared repositories.

The primary uses of the git remote command are to list existing remotes, add new remote connections, and remove remotes that are no longer needed.

  • Listing remotes: Simply typing git remote will list all the remote repositories connected to your local repository.
  • Adding remotes: To add a new remote, you use git remote add followed by a name for the remote and its URL.
  • Removing remotes: To remove a remote, you use git remote remove followed by the name of the remote you want to remove.

Examples

List all remotes in the repository:

git remote

List all remotes with their URLs (-v is shorthand for --verbose, meaning show extra details):

git remote -v

Add a new remote named 'upstream' pointing to a repository URL:

git remote add upstream https://github.com/original-author/project.git

Remove a remote named 'old-backup':

git remote remove old-backup

When you clone a repository, Git automatically creates a remote named origin that points to the repository you cloned from. This is the default remote for most operations like git push and git pull.

Show detailed information about the 'origin' remote:

git remote show origin

Rename a remote from 'origin' to 'main-repo':

git remote rename origin main-repo
© 2024-2025 GitByBit.All rights reserved.

Hi! I'm Alex, creator of GitByBit.

And this is Gitopedia—a reference that summarizes knowledge in my Git course.

Gitopedia is designed to be a personal knowledge base. When you progress through the main Git course in VS Code, you unlock all of these topics, one by one, bit by bit. This gives you time to digest the information and gradually build the mental model of Git. Here's an example of how it works:

Learning directly in VS Code lets you practice Git exactly as you would in real life, doing real jobs, writing real code. In addition, the course has access to your actual terminal, so it can point out mistakes, suggest workarounds, etc.

The course is FREE, there are no Ads or other bullshit. There are optional premium add-ons you can purchase, mainly to support my work (regrettably, I have to eat every day), but that's totally up to you.

Learn Git in VS Code