Tuesday, 18 October 2011

Git - Track remote branch from existing local branch

Issuing the Git Clone command (git clone remote-branch local-branch) will get a latest version of the remote branch and update the local-branch config file to track the remote-branch.

How about if the local-branch exists already and all you want to do is tell git to start tracking the remote-branch from the local-branch without overidding all changes in the local-branch?

Try the following command;

git branch --set-upstream local-branch origin/remote-branch

To update your local set up with all available remote branches for a particular remote repository, try

git remote update
git branch -a
git checkout "branchname"

You can create a new remote branch from a local branch by simply issuing a push to the remote repository and specifying the new branch name like so

git push -u origin "new branch name"

No comments:

Post a Comment