I am working on a new project and would like to start with a seed project which I have found on GitHub.
I have cloned the seed project locally, it now shows 1 remote branch when I execute the command:
git remote -v
how can switch between the 2 remotes
You don't exactly "switch", you simply mention the name of the remote you want to use:
git push origin # or git push remote2
That way, you can pull from one remote and push to another.
You could even use only one remote (the default origin one), and set a different push url:
git remote set-url --push origin email@example.com:repo.git
I don't think commands like
git checkoutwill work when working on 2 branches from 2 different remotes.
git checkout is more for local branches.
You can create a local branch based on a remote tracking branch:
git checkout -b abranch remote2/abranch
While the other remote which is my origin is my private remote and I will be mainly working on that remote and doing pull and push.
On the upstream remote I will only be doing pull.
That is the definition of the triangular workflows:
You clone from
origin as usual, but fetch form upstream.
$ git remote add upstream https://github.com/atom/atom $ git fetch upstream
Create local branches based on origin/abranch, but don't forget to rebase that branch on top of upstream/abranch, whenever a fetch brings new commits from upstream.
git checkout -b abranch origin/abranch git rebase upstream/abranch git push --force