Cao Yi

Work with Multiple Remote Repositories


Usually, a local git repository tracks a default remote repository named origin. However, we also needs to work with multiple remote repositories in some cases.

When we folk a project from GitHub and want to fetch the latest changes from the original project, or when we work with a git mirror, or we have two IP of a same repository and the connections are not stable, we would need it.

Add Multiple Remote Repositories

E.g., we’ll add another remote repository named chengdu:

$ git remote add chengdu ssh://git@

List all remote repositories:

$ git remote --v
chengdu  ssh://git@ (fetch)
chengdu  ssh://git@ (push)
origin  ssh://git@ (fetch)
origin  ssh://git@ (push)

The abbr command git pull is not allowed when there are multiple remote repositories.

The remote repository must be filled in the command:

$ git pull chengdu master


$ git pull origin master

How to View the remote git URL?

List all remote repositories:

git remote -v

or list one: