This page describes how to use remote branches in git, when setup in a manner similar to subversion.
Creating a branch
First we create an ordinary branch, called experimental-branch:
git branch experimental-branch
Then we push it to the server:
git push origin experimental-branch
Listing branches
List all branches:
git branch -a
The one with the asterisk is the current branch.
Create a local branch to track a remote one
I don’t remember what the -b is for:
git checkout --track -b experimental-branch origin/experimental-branch
That is two dashes before track instead of a long one. WordPress don’t seem to handle this very well …
Note: If you get errors along the line of
fatal: git checkout: updating paths is incompatible with switching branches/forcing
Did you intend to checkout 'origin/experimental-branch' which can not be resolved as commit?
, then you might want to run:
git fetch
Switching to a branch
Simply check it out:
git checkout experimental-branch
Comitting within a branch
You are always in some branch. It does not matter if it is named master or something else.
Pushing to a remote branch from a tracking branch
If the current branch is tracking some remote branch, it is as simple as:
git push
Merging back a branch
Merging from some branch is done by:
git merge experimental-branch
Other sources
Tags: git, remote branch
March 28, 2009 at 2:38 am |
[...] Working with remote branches By aslakjohansen Note: Better description here [...]