git remote
git remote: manage remote repositories.
The git remote command is used to manage connections to remote repositories.
In Git, a remote 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.
It's very common to shorten remote repository to just remote. When you hear someone says "add a remote" or "push to the remote", they are referring to a remote Git repository (and not some sort of remote control device).
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 remotewill list all the remote repositories connected to your local repository. - Adding remotes: To add a new remote, you use
git remote addfollowed by a name for the remote and its URL. - Removing remotes: To remove a remote, you use
git remote removefollowed by the name of the remote you want to remove.
Examples
List all remotes in the repository:
git remoteList all remotes with their URLs (-v is shorthand for --verbose, meaning show extra details):
git remote -vAdd a new remote named 'upstream' pointing to a repository URL:
git remote add upstream https://github.com/original-author/project.gitRemove a remote named 'old-backup':
git remote remove old-backupWhen 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 originRename a remote from 'origin' to 'main-repo':
git remote rename origin main-repo