Skip to content

Git Remote as a Branch

Cheng-Yu Hsu edited this page Sep 27, 2016 · 1 revision

Setup Remote as a Branch

To setup a remote as a branch, first add a remote, fetch it, and bind it.

Add a remote

git remote add <remote_name> <remote_uri>

Fetch the remote

git fetch <remote_name>

Bind it to a local branch

git checkout -b <local_branch_name> <remote_name>/<remote_branch>

Example

$ git remote add root <some_url>
$ git fetch root
	From <domain_name>:<repo_name>
 	* [new branch]      master     -> root/master
$ git checkout -b root root/master
	Branch root set up to track remote branch master from root.
	Switched to a new branch 'root'

Clone this wiki locally