1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.1//EN"
2 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3 <html xmlns=
"http://www.w3.org/1999/xhtml" xml:
lang=
"en">
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8" />
6 <meta name=
"generator" content=
"AsciiDoc 8.2.5" />
7 <style type=
"text/css">
9 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
11 border: 1px solid red;
16 margin: 1em 5% 1em 5%;
21 text-decoration: underline
;
39 h1
, h2
, h3
, h4
, h5
, h6
{
41 font-family: sans-serif
;
48 border-bottom: 2px solid silver
;
66 border: 1px solid silver
;
81 font-family: sans-serif
;
88 font-family: sans-serif
;
92 font-family: sans-serif
;
94 border-top: 2px solid silver
;
100 padding-bottom: 0.5em;
104 padding-bottom: 0.5em;
108 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
109 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
110 div
.admonitionblock
{
113 margin-bottom: 1.5em;
115 div
.admonitionblock
{
117 margin-bottom: 2.5em;
120 div
.content
{ /* Block element content. */
124 /* Block element titles. */
125 div
.title
, caption
.title
{
126 font-family: sans-serif
;
130 margin-bottom: 0.5em;
136 td div
.title:first-child
{
139 div
.content div
.title:first-child
{
142 div
.content
+ div
.title
{
146 div
.sidebarblock
> div
.content
{
148 border: 1px solid silver
;
155 div
.listingblock
> div
.content
{
156 border: 1px solid silver
;
161 div
.quoteblock
> div
.content
{
168 div
.verseblock
+ div
.attribution
{
172 div
.admonitionblock
.icon
{
176 text-decoration: underline
;
178 padding-right: 0.5em;
180 div
.admonitionblock td
.content
{
182 border-left: 2px solid silver
;
185 div
.exampleblock
> div
.content
{
186 border-left: 2px solid silver
;
190 div
.verseblock div
.content
{
194 div
.imageblock div
.content
{ padding-left: 0; }
195 div
.imageblock img
{ border: 1px solid silver
; }
196 span
.image img
{ border-style: none
; }
200 margin-bottom: 0.8em;
212 list-style-position: outside
;
215 list-style-type: lower-alpha
;
218 div
.tableblock
> table
{
219 border: 3px solid
#527bbd;
222 font-family: sans-serif
;
231 margin-bottom: 0.8em;
239 padding-right: 0.8em;
246 div#footer-badges
{ display: none
; }
251 font-family: sans-serif
;
255 margin-bottom: 0.1em;
258 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
274 include1::./stylesheets
/xhtml11-manpage
.css
[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div
.sidebar-content
{
279 border: 1px solid silver
;
282 div
.sidebar-title
, div
.image-title
{
283 font-family: sans-serif
;
286 margin-bottom: 0.5em;
289 div
.listingblock div
.content
{
290 border: 1px solid silver
;
295 div
.quoteblock-content
{
299 div
.exampleblock-content
{
300 border-left: 2px solid silver
;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc
a:visited
{ color: blue
; }
307 <title>git-branch(
1)
</title>
312 git-branch(
1) Manual Page
315 <div class=
"sectionbody">
317 List, create, or delete branches
322 <div class=
"sectionbody">
323 <div class=
"verseblock">
324 <div class=
"content"><em>git branch
</em> [--color | --no-color] [-r | -a]
325 [-v [--abbrev=
<length
> | --no-abbrev]]
326 [(--merged | --no-merged | --contains) [
<commit
>]]
327 <em>git branch
</em> [--track | --no-track] [-l] [-f]
<branchname
> [
<start-point
>]
328 <em>git branch
</em> (-m | -M) [
<oldbranch
>]
<newbranch
>
329 <em>git branch
</em> (-d | -D) [-r]
<branchname
>…</div></div>
331 <h2 id=
"_description">DESCRIPTION
</h2>
332 <div class=
"sectionbody">
333 <div class=
"para"><p>With no arguments, existing branches are listed and the current branch will
334 be highlighted with an asterisk. Option
<tt>-r
</tt> causes the remote-tracking
335 branches to be listed, and option
<tt>-a
</tt> shows both.
</p></div>
336 <div class=
"para"><p>With
<tt>--contains
</tt>, shows only the branches that contain the named commit
337 (in other words, the branches whose tip commits are descendants of the
338 named commit). With
<tt>--merged
</tt>, only branches merged into the named
339 commit (i.e. the branches whose tip commits are reachable from the named
340 commit) will be listed. With
<tt>--no-merged
</tt> only branches not merged into
341 the named commit will be listed. If the
<commit
> argument is missing it
342 defaults to
<em>HEAD
</em> (i.e. the tip of the current branch).
</p></div>
343 <div class=
"para"><p>The command's second form creates a new branch head named
<branchname
>
344 which points to the current
<em>HEAD
</em>, or
<start-point
> if given.
</p></div>
345 <div class=
"para"><p>Note that this will create the new branch, but it will not switch the
346 working tree to it; use
"git checkout <newbranch>" to switch to the
347 new branch.
</p></div>
348 <div class=
"para"><p>When a local branch is started off a remote branch, git sets up the
349 branch so that
<em>git-pull
</em> will appropriately merge from
350 the remote branch. This behavior may be changed via the global
351 <tt>branch.autosetupmerge
</tt> configuration flag. That setting can be
352 overridden by using the
<tt>--track
</tt> and
<tt>--no-track
</tt> options.
</p></div>
353 <div class=
"para"><p>With a
<em>-m
</em> or
<em>-M
</em> option,
<oldbranch
> will be renamed to
<newbranch
>.
354 If
<oldbranch
> had a corresponding reflog, it is renamed to match
355 <newbranch
>, and a reflog entry is created to remember the branch
356 renaming. If
<newbranch
> exists, -M must be used to force the rename
358 <div class=
"para"><p>With a
<tt>-d
</tt> or
<tt>-D
</tt> option,
<tt><branchname
></tt> will be deleted. You may
359 specify more than one branch for deletion. If the branch currently
360 has a reflog then the reflog will also be deleted.
</p></div>
361 <div class=
"para"><p>Use -r together with -d to delete remote-tracking branches. Note, that it
362 only makes sense to delete remote-tracking branches if they no longer exist
363 in the remote repository or if
<em>git-fetch
</em> was configured not to fetch
364 them again. See also the
<em>prune
</em> subcommand of
<a href=
"git-remote.html">git-remote(
1)
</a> for a
365 way to clean up all obsolete remote-tracking branches.
</p></div>
367 <h2 id=
"_options">OPTIONS
</h2>
368 <div class=
"sectionbody">
369 <div class=
"vlist"><dl>
375 Delete a branch. The branch must be fully merged in HEAD.
383 Delete a branch irrespective of its merged status.
391 Create the branch's reflog. This activates recording of
392 all changes made to the branch ref, enabling use of date
393 based sha1 expressions such as
"<branchname>@{yesterday}".
404 Reset
<branchname
> to
<startpoint
> if
<branchname
> exists
405 already. Without
<tt>-f
</tt> <em>git-branch
</em> refuses to change an existing branch.
413 Move/rename a branch and the corresponding reflog.
421 Move/rename a branch even if the new branch name already exists.
429 Color branches to highlight current, local, and remote branches.
437 Turn off branch colors, even when the configuration file gives the
438 default to color output.
446 List or delete (if used with -d) the remote-tracking branches.
454 List both remote-tracking branches and local branches.
465 Show sha1 and commit subject line for each head, along with
466 relationship to upstream branch (if any). If given twice, print
467 the name of the upstream branch, as well.
471 --abbrev=
<length
>
475 Alter the sha1's minimum display length in the output listing.
476 The default value is
7.
484 Display the full sha1s in the output listing rather than abbreviating them.
495 When creating a new branch, set up configuration to mark the
496 start-point branch as
"upstream" from the new branch. This
497 configuration will tell git to show the relationship between the
498 two branches in
<tt>git status
</tt> and
<tt>git branch -v
</tt>. Furthermore,
499 it directs
<tt>git pull
</tt> without arguments to pull from the
500 upstream when the new branch is checked out.
502 <div class=
"para"><p>This behavior is the default when the start point is a remote branch.
503 Set the branch.autosetupmerge configuration variable to
<tt>false
</tt> if you
504 want
<tt>git checkout
</tt> and
<tt>git branch
</tt> to always behave as if
<em>--no-track
</em>
505 were given. Set it to
<tt>always
</tt> if you want this behavior when the
506 start-point is either a local or remote branch.
</p></div>
513 Do not set up
"upstream" configuration, even if the
514 branch.autosetupmerge configuration variable is true.
518 --contains
<commit
>
522 Only list branches which contain the specified commit.
526 --merged [
<commit
>]
530 Only list branches whose tips are reachable from the
531 specified commit (HEAD if not specified).
535 --no-merged [
<commit
>]
539 Only list branches whose tips are not reachable from the
540 specified commit (HEAD if not specified).
548 The name of the branch to create or delete.
549 The new branch name must pass all checks defined by
550 <a href=
"git-check-ref-format.html">git-check-ref-format(
1)
</a>. Some of these checks
551 may restrict the characters allowed in a branch name.
559 The new branch head will point to this commit. It may be
560 given as a branch name, a commit-id, or a tag. If this
561 option is omitted, the current HEAD will be used instead.
569 The name of an existing branch to rename.
577 The new name for an existing branch. The same restrictions as for
578 <branchname
> apply.
583 <h2 id=
"_examples">Examples
</h2>
584 <div class=
"sectionbody">
585 <div class=
"vlist"><dl>
587 Start development from a known tag
590 <div class=
"listingblock">
591 <div class=
"content">
592 <pre><tt>$ git clone git://git.kernel.org/pub/scm/.../linux-
2.6 my2.6
594 $ git branch my2.6
.14 v2.6
.14 <b>(
1)
</b>
595 $ git checkout my2.6
.14</tt></pre>
597 <div class=
"colist"><ol>
600 This step and the next one could be combined into a single step with
601 "checkout -b my2.6.14 v2.6.14".
607 Delete an unneeded branch
610 <div class=
"listingblock">
611 <div class=
"content">
612 <pre><tt>$ git clone git://git.kernel.org/.../git.git my.git
614 $ git branch -d -r origin/todo origin/html origin/man
<b>(
1)
</b>
615 $ git branch -D test
<b>(
2)
</b></tt></pre>
617 <div class=
"colist"><ol>
620 Delete the remote-tracking branches
"todo",
"html" and
"man". The next
621 <em>fetch
</em> or
<em>pull
</em> will create them again unless you configure them not to.
622 See
<a href=
"git-fetch.html">git-fetch(
1)
</a>.
627 Delete the
"test" branch even if the
"master" branch (or whichever branch
628 is currently checked out) does not have all commits from the test branch.
635 <h2 id=
"_notes">Notes
</h2>
636 <div class=
"sectionbody">
637 <div class=
"para"><p>If you are creating a branch that you want to checkout immediately, it is
638 easier to use the git checkout command with its
<tt>-b
</tt> option to create
639 a branch and check it out with a single command.
</p></div>
640 <div class=
"para"><p>The options
<tt>--contains
</tt>,
<tt>--merged
</tt> and
<tt>--no-merged
</tt> serve three related
641 but different purposes:
</p></div>
642 <div class=
"ilist"><ul>
645 <tt>--contains
<commit
></tt> is used to find all branches which will need
646 special attention if
<commit
> were to be rebased or amended, since those
647 branches contain the specified
<commit
>.
652 <tt>--merged
</tt> is used to find all branches which can be safely deleted,
653 since those branches are fully contained by HEAD.
658 <tt>--no-merged
</tt> is used to find branches which are candidates for merging
659 into HEAD, since those branches are not fully contained by HEAD.
664 <h2 id=
"_see_also">SEE ALSO
</h2>
665 <div class=
"sectionbody">
666 <div class=
"para"><p><a href=
"git-check-ref-format.html">git-check-ref-format(
1)
</a>,
667 <a href=
"git-fetch.html">git-fetch(
1)
</a>,
668 <a href=
"git-remote.html">git-remote(
1)
</a>,
669 <a href=
"user-manual.html#what-is-a-branch">“Understanding history: What is
670 a branch?
”</a> in the Git User's Manual.
</p></div>
672 <h2 id=
"_author">Author
</h2>
673 <div class=
"sectionbody">
674 <div class=
"para"><p>Written by Linus Torvalds
<torvalds@osdl.org
> and Junio C Hamano
<gitster@pobox.com
></p></div>
676 <h2 id=
"_documentation">Documentation
</h2>
677 <div class=
"sectionbody">
678 <div class=
"para"><p>Documentation by Junio C Hamano and the git-list
<git@vger.kernel.org
>.
</p></div>
680 <h2 id=
"_git">GIT
</h2>
681 <div class=
"sectionbody">
682 <div class=
"para"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
685 <div id=
"footer-text">
686 Last updated
2009-
12-
03 09:
12:
27 UTC