git new-branch <branch_name> git new-branch --upstream_current <branch_name> git new-branch --upstream <REF> <branch_name> git new-branch --lkgr <branch_name>
Creates a new branch. By default the new branch will track the configured upstream for the repo (defaults to origin/master). If one of the other options is specified, it will track that other ref instead.
Conceptually, each branch in your repo represents one Change List (CL). If you
have many independent CLs (i.e. the changes in one do not interact with/depend
on the changes in another), then you should create them as new branches tracking
the default upstream (i.e.
git new-branch <branch_name>). If you have features
which depend on each other, you should create stacked branches using
new-branch --upstream_current <branch_name>.
Set the tracking (upstream) branch to the currently-checked-out branch.
- --uptstream <REF>
Set the tracking (upstream) branch to <REF>. <REF> may be a local branch, remote branch, or a tag.
The name for the new branch.
This configures the default upstream for all new branches. If it is unset, it defaults to origin/master. This is considered to be the root branch.
$ git map-branches origin/master cool_feature subfeature fixit frozen_branch * $ git new-branch independent_cl $ git map-branches origin/master cool_feature subfeature fixit frozen_branch independent_cl * $ git new-branch --upstream subfeature nested_cl $ git map-branches origin/master cool_feature subfeature <1> nested_cl * fixit frozen_branch independent_cl $ git checkout cool_feature Switched to branch 'cool_feature' Your branch is ahead of 'origin/master' by 4 commits. (use "git push" to publish your local commits) $ git new-branch --upstream_current cl_depends_on_cool_feature $ git map-branches origin/master cool_feature cl_depends_on_cool_feature * subfeature nested_cl fixit frozen_branch independent_cl
Note that both branches are cyan because they are currently the same commit object. See git-map-branches(1) for more detail.
Some common short-hand aliases. Feel free to add these to your ~/.gitconfig file.
[alias] git nb = new-branch git tb = new-branch --upstream_current <1>
mnemonic: tb → "track branch"