git remote is a command used in Git to show a list of currently configured remote repositories. A remote repository is a version of your project that is hosted on a server and accessible over the internet or a network.
When you clone a repository, Git automatically creates a remote called “origin” that points to the original repository. However, you can create additional remotes to connect to other repositories, such as a fork of the original repository, a colleague’s repo, or a backup location.
The git remote command shows the names of all the remote repositories associated with your project. By default, it lists the short names of each remote repository, such as “origin”. You can use the -v option to display the URLs of the remote repositories as well.
Syntax:
git remote [option]
Options:
-v: shows the names and URLs of all remote repositoriesadd <name> <url>: adds a new remote repository with the specified name and URLremove <name>: removes the remote repository with the specified namerename <old-name> <new-name>: renames the remote repository from the old name to the new nameset-head <name> <branch>: sets the default branch for the remote repository with the specified name
Example usage:
To list all remote repositories:
$ git remote
origin
upstream
To list remote repositories along with their URLs:
$ git remote -v
origin https://github.com/username/repo.git (fetch)
origin https://github.com/username/repo.git (push)
upstream https://github.com/upstream-user/repo.git (fetch)
upstream https://github.com/upstream-user/repo.git (push)
To add a new remote repository:
$ git remote add myfork https://github.com/myusername/repo.git
To remove a remote repository:
$ git remote remove upstream
To change the name of a remote repository:
$ git remote rename origin myorigin




