1GIT-BRANCH(1)                     Git Manual                     GIT-BRANCH(1)
2
3
4

NAME

6       git-branch - List, create, or delete branches
7

SYNOPSIS

9           git-branch [--color | --no-color] [-r | -a]
10                      [-v [--abbrev=<length> | --no-abbrev]]
11           git-branch [--track | --no-track] [-l] [-f] <branchname> [<start-point>]
12           git-branch (-m | -M) [<oldbranch>] <newbranch>
13           git-branch (-d | -D) [-r] <branchname>...
14

DESCRIPTION

16       With no arguments given a list of existing branches will be shown, the
17       current branch will be highlighted with an asterisk. Option -r causes
18       the remote-tracking branches to be listed, and option -a shows both.
19
20       In its second form, a new branch named <branchname> will be created. It
21       will start out with a head equal to the one given as <start-point>. If
22       no <start-point> is given, the branch will be created with a head equal
23       to that of the currently checked out branch.
24
25       When a local branch is started off a remote branch, git can setup the
26       branch so that git-pull(1) will appropriately merge from that remote
27       branch. If this behavior is desired, it is possible to make it the
28       default using the global branch.autosetupmerge configuration flag.
29       Otherwise, it can be chosen per-branch using the --track and --no-track
30       options.
31
32       With a -m or -M option, <oldbranch> will be renamed to <newbranch>. If
33       <oldbranch> had a corresponding reflog, it is renamed to match
34       <newbranch>, and a reflog entry is created to remember the branch
35       renaming. If <newbranch> exists, -M must be used to force the rename to
36       happen.
37
38       With a -d or -D option, <branchname> will be deleted. You may specify
39       more than one branch for deletion. If the branch currently has a reflog
40       then the reflog will also be deleted. Use -r together with -d to delete
41       remote-tracking branches.
42

OPTIONS

44       -d
45           Delete a branch. The branch must be fully merged.
46
47       -D
48           Delete a branch irrespective of its index status.
49
50       -l
51           Create the branch´s reflog. This activates recording of all changes
52           made to the branch ref, enabling use of date based sha1 expressions
53           such as "<branchname>@{yesterday}".
54
55       -f
56           Force the creation of a new branch even if it means deleting a
57           branch that already exists with the same name.
58
59       -m
60           Move/rename a branch and the corresponding reflog.
61
62       -M
63           Move/rename a branch even if the new branchname already exists.
64
65       --color
66           Color branches to highlight current, local, and remote branches.
67
68       --no-color
69           Turn off branch colors, even when the configuration file gives the
70           default to color output.
71
72       -r
73           List or delete (if used with -d) the remote-tracking branches.
74
75       -a
76           List both remote-tracking branches and local branches.
77
78       -v
79           Show sha1 and commit subject line for each head.
80
81       --abbrev=<length>
82           Alter minimum display length for sha1 in output listing, default
83           value is 7.
84
85       --no-abbrev
86           Display the full sha1s in output listing rather than abbreviating
87           them.
88
89       <branchname>
90           The name of the branch to create or delete. The new branch name
91           must pass all checks defined by git-check-ref-format(1). Some of
92           these checks may restrict the characters allowed in a branch name.
93
94       <start-point>
95           The new branch will be created with a HEAD equal to this. It may be
96           given as a branch name, a commit-id, or a tag. If this option is
97           omitted, the current branch is assumed.
98
99       <oldbranch>
100           The name of an existing branch to rename.
101
102       <newbranch>
103           The new name for an existing branch. The same restrictions as for
104           <branchname> applies.
105

EXAMPLES

107       Start development off of a known tag
108
109
110               $ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
111               $ cd my2.6
112               $ git branch my2.6.14 v2.6.14   (1)
113               $ git checkout my2.6.14
114
115
116           1. This step and the next one could be combined into a single step
117           with "checkout -b my2.6.14 v2.6.14".
118
119       Delete unneeded branch
120
121
122               $ git clone git://git.kernel.org/.../git.git my.git
123               $ cd my.git
124               $ git branch -d -r origin/todo origin/html origin/man   (1)
125               $ git branch -D test                                    (2)
126
127
128           1. Delete remote-tracking branches "todo", "html", "man"
129           2. Delete "test" branch even if the "master" branch does not have
130           all commits from test branch.
131

NOTES

133       If you are creating a branch that you want to immediately checkout,
134       it´s easier to use the git checkout command with its -b option to
135       create a branch and check it out with a single command.
136

AUTHOR

138       Written by Linus Torvalds <torvalds@osdl.org> and Junio C Hamano
139       <junkio@cox.net>
140

DOCUMENTATION

142       Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
143

GIT

145       Part of the git(7) suite
146
147
148
149
150Git 1.5.3.3                       10/09/2007                     GIT-BRANCH(1)
Impressum