Most important branching commands
# list local branches git branch -v # list all (including remote) branches git branch -av # create a branch git branch <branchname> # checkout (switch to) branch git checkout <branchname>
Development (master) branch
The master branch corresponds to the former SVN trunk. Customarily, development occurs primarily on this branch.
- Changes in branch master require a review in Gerrit before they are accepted.
- Don't commit on branch master; fork off a topic branch from it.
Release (version) branches
Release branches are long living public branches that are maintained for a long time period, for example:
- Release branches cant be changed without Gerrit review.
- Don't commit on release branches; fork off a topic branch from them.
- You should always work in a topic branch, also called feature branch.
- A topic branch is a local branch that exists for the purpose of keeping changes in a descriptively named branch.
Things that you could consider for naming branches are the bugtracker reference, destination branch, and/or a meaningful description. Some examples:
(Using slashes you get grouping support in some GUI tools like gitx):
Detached head is a term that describes when your working directory does not belong to any branch; which happens when you checkout a specific commit. Useful for quick checkouts of a change request/RFC from Gerrit, which you can then turn either into a topic branch for later referral by
git checkout -b <topic-branch> or fix by checking out a branch that you already created earlier by
git checkout <topic-branch>