As explained earlier Git is a distributed system. So we need to have a way to push and pull changes from other repositories.
When you clone an existing repository you will already have a remote in your local repository. The default name of this remote is “origin”. When you cloned this repository from github for example the remote origin will be pointing to github (containing the information needed to communicate with this server).
You can list the remotes that are part of this repository with the following command:
$ git remote
To view their respective URLs:
$ git remote -v
Sometimes you want to add a new remote to the repository, let’s say you would like to push some branch to Bitbucket for example:
$ git remote add bitbucket git@bitbucket.com/somerepo.git
This will add a new remote with the name bitbucket.
Now when you want to push a branch to this remote, you can use the following command:
$ git push bitbucket feature-some-feature-description
Removing a remote is also possible:
$ git remote remove bitbucket