Home > Blockchain >  How to switch between two different remote origin in git
How to switch between two different remote origin in git

Time:09-08

Suppose you have two remotes set for your project. For example: One remote named ABC points to Microsoft Azure Devops and other remote named XYZ points to github. How do you switch the remote branch to which local master branch is currently pointing at?

CodePudding user response:

The way I do this trick is by using --set-upstream-to

git checkout local-branch
git branch --set-upstream-to=one-remote/remote-branch

It the branches have the same name in local and remote:

git checkout local-branch
git branch --set-upstream-to=one-remote

CodePudding user response:

To switch between two remotes we have to use git remote set-head <name of remote> -a. suppose you have two remote namely ABC and XYZ. And your master branch is pointing at ABC and you would like to make it point at XYZ. Then you will type following command in terminal.

git remote set-head XYZ -a

Hope this helps.

  • Related