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.4.5" />
7 <title>git-branch(
1)
</title>
8 <style type=
"text/css">
10 p
, li
, dt
, dd
, div
, pre
, h1
, h2
, h3
, h4
, h5
, h6
{
12 border: 1px solid red;
17 margin: 1em 5% 1em 5%;
22 text-decoration: underline
;
42 h1
, h2
, h3
, h4
, h5
, h6
{
44 font-family: sans-serif
;
51 border-bottom: 2px solid silver
;
69 border: 1px solid silver
;
88 font-family: sans-serif
;
94 span#revnumber
, span#revdate
, span#revremark
{
95 font-family: sans-serif
;
99 font-family: sans-serif
;
101 border-top: 2px solid silver
;
107 padding-bottom: 0.5em;
111 padding-bottom: 0.5em;
116 margin-bottom: 1.5em;
118 div
.tableblock
, div
.imageblock
, div
.exampleblock
, div
.verseblock
,
119 div
.quoteblock
, div
.literalblock
, div
.listingblock
, div
.sidebarblock
,
120 div
.admonitionblock
{
122 margin-bottom: 1.5em;
124 div
.admonitionblock
{
126 margin-bottom: 2.5em;
129 div
.content
{ /* Block element content. */
133 /* Block element titles. */
134 div
.title
, caption
.title
{
136 font-family: sans-serif
;
140 margin-bottom: 0.5em;
146 td div
.title:first-child
{
149 div
.content div
.title:first-child
{
152 div
.content
+ div
.title
{
156 div
.sidebarblock
> div
.content
{
158 border: 1px solid silver
;
162 div
.listingblock
> div
.content
{
163 border: 1px solid silver
;
172 div
.quoteblock
> div
.attribution
{
181 div
.verseblock
> div
.content
{
184 div
.verseblock
> div
.attribution
{
188 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
189 div
.verseblock
+ div
.attribution
{
193 div
.admonitionblock
.icon
{
197 text-decoration: underline
;
199 padding-right: 0.5em;
201 div
.admonitionblock td
.content
{
203 border-left: 2px solid silver
;
206 div
.exampleblock
> div
.content
{
207 border-left: 2px solid silver
;
211 div
.imageblock div
.content
{ padding-left: 0; }
212 span
.image img
{ border-style: none
; }
213 a
.image:visited
{ color: white
; }
217 margin-bottom: 0.8em;
230 list-style-position: outside
;
233 list-style-type: decimal
;
236 list-style-type: lower-alpha
;
239 list-style-type: upper-alpha
;
242 list-style-type: lower-roman
;
245 list-style-type: upper-roman
;
248 div
.compact ul
, div
.compact ol
,
249 div
.compact p
, div
.compact p
,
250 div
.compact div
, div
.compact div
{
252 margin-bottom: 0.1em;
255 div
.tableblock
> table
{
256 border: 3px solid
#527bbd;
259 font-family: sans-serif
;
271 /* Because the table frame attribute is overriden by CSS in most browsers. */
272 div
.tableblock
> table
[frame
="void"] {
275 div
.tableblock
> table
[frame
="hsides"] {
276 border-left-style: none
;
277 border-right-style: none
;
279 div
.tableblock
> table
[frame
="vsides"] {
280 border-top-style: none
;
281 border-bottom-style: none
;
287 margin-bottom: 0.8em;
290 padding-bottom: 15px;
292 dt
.hdlist1
.strong
, td
.hdlist1
.strong
{
298 padding-right: 0.8em;
304 div
.hdlist
.compact tr
{
314 div#footer-badges
{ display: none
; }
319 font-family: sans-serif
;
323 margin-bottom: 0.1em;
326 div
.toclevel1
, div
.toclevel2
, div
.toclevel3
, div
.toclevel4
{
342 /* Overrides for manpage documents */
345 padding-bottom: 0.5em;
346 border-top: 2px solid silver
;
347 border-bottom: 2px solid silver
;
357 div#toc
{ display: none
; }
360 /* Workarounds for IE6's broken and incomplete CSS2. */
362 div
.sidebar-content
{
364 border: 1px solid silver
;
367 div
.sidebar-title
, div
.image-title
{
369 font-family: sans-serif
;
372 margin-bottom: 0.5em;
375 div
.listingblock div
.content
{
376 border: 1px solid silver
;
381 div
.quoteblock-attribution
{
386 div
.verseblock-content
{
389 div
.verseblock-attribution
{
394 div
.exampleblock-content
{
395 border-left: 2px solid silver
;
399 /* IE6 sets dynamically generated links as visited. */
400 div#toc
a:visited
{ color: blue
; }
406 git-branch(
1) Manual Page
409 <div class=
"sectionbody">
411 List, create, or delete branches
415 <h2 id=
"_synopsis">SYNOPSIS
</h2>
416 <div class=
"sectionbody">
417 <div class=
"verseblock">
418 <div class=
"verseblock-content"><em>git branch
</em> [--color[=
<when
>] | --no-color] [-r | -a]
419 [-v [--abbrev=
<length
> | --no-abbrev]]
420 [(--merged | --no-merged | --contains) [
<commit
>]]
421 <em>git branch
</em> [--set-upstream | --track | --no-track] [-l] [-f]
<branchname
> [
<start-point
>]
422 <em>git branch
</em> (-m | -M) [
<oldbranch
>]
<newbranch
>
423 <em>git branch
</em> (-d | -D) [-r]
<branchname
>…</div>
424 <div class=
"verseblock-attribution">
427 <h2 id=
"_description">DESCRIPTION
</h2>
428 <div class=
"sectionbody">
429 <div class=
"paragraph"><p>With no arguments, existing branches are listed and the current branch will
430 be highlighted with an asterisk. Option
<tt>-r
</tt> causes the remote-tracking
431 branches to be listed, and option
<tt>-a
</tt> shows both.
</p></div>
432 <div class=
"paragraph"><p>With
<tt>--contains
</tt>, shows only the branches that contain the named commit
433 (in other words, the branches whose tip commits are descendants of the
434 named commit). With
<tt>--merged
</tt>, only branches merged into the named
435 commit (i.e. the branches whose tip commits are reachable from the named
436 commit) will be listed. With
<tt>--no-merged
</tt> only branches not merged into
437 the named commit will be listed. If the
<commit
> argument is missing it
438 defaults to
<em>HEAD
</em> (i.e. the tip of the current branch).
</p></div>
439 <div class=
"paragraph"><p>The command
’s second form creates a new branch head named
<branchname
>
440 which points to the current
<em>HEAD
</em>, or
<start-point
> if given.
</p></div>
441 <div class=
"paragraph"><p>Note that this will create the new branch, but it will not switch the
442 working tree to it; use
"git checkout <newbranch>" to switch to the
443 new branch.
</p></div>
444 <div class=
"paragraph"><p>When a local branch is started off a remote-tracking branch, git sets up the
445 branch so that
<em>git pull
</em> will appropriately merge from
446 the remote-tracking branch. This behavior may be changed via the global
447 <tt>branch.autosetupmerge
</tt> configuration flag. That setting can be
448 overridden by using the
<tt>--track
</tt> and
<tt>--no-track
</tt> options, and
449 changed later using
<tt>git branch --set-upstream
</tt>.
</p></div>
450 <div class=
"paragraph"><p>With a
<em>-m
</em> or
<em>-M
</em> option,
<oldbranch
> will be renamed to
<newbranch
>.
451 If
<oldbranch
> had a corresponding reflog, it is renamed to match
452 <newbranch
>, and a reflog entry is created to remember the branch
453 renaming. If
<newbranch
> exists, -M must be used to force the rename
455 <div class=
"paragraph"><p>With a
<tt>-d
</tt> or
<tt>-D
</tt> option,
<tt><branchname
></tt> will be deleted. You may
456 specify more than one branch for deletion. If the branch currently
457 has a reflog then the reflog will also be deleted.
</p></div>
458 <div class=
"paragraph"><p>Use -r together with -d to delete remote-tracking branches. Note, that it
459 only makes sense to delete remote-tracking branches if they no longer exist
460 in the remote repository or if
<em>git fetch
</em> was configured not to fetch
461 them again. See also the
<em>prune
</em> subcommand of
<a href=
"git-remote.html">git-remote(
1)
</a> for a
462 way to clean up all obsolete remote-tracking branches.
</p></div>
464 <h2 id=
"_options">OPTIONS
</h2>
465 <div class=
"sectionbody">
466 <div class=
"dlist"><dl>
472 Delete a branch. The branch must be fully merged in its
473 upstream branch, or in
<tt>HEAD
</tt> if no upstream was set with
474 <tt>--track
</tt> or
<tt>--set-upstream
</tt>.
482 Delete a branch irrespective of its merged status.
490 Create the branch
’s reflog. This activates recording of
491 all changes made to the branch ref, enabling use of date
492 based sha1 expressions such as
"<branchname>@{yesterday}".
493 Note that in non-bare repositories, reflogs are usually
494 enabled by default by the
<tt>core.logallrefupdates
</tt> config option.
505 Reset
<branchname
> to
<startpoint
> if
<branchname
> exists
506 already. Without
<tt>-f
</tt> <em>git branch
</em> refuses to change an existing branch.
514 Move/rename a branch and the corresponding reflog.
522 Move/rename a branch even if the new branch name already exists.
526 --color[=
<when
>]
530 Color branches to highlight current, local, and
531 remote-tracking branches.
532 The value must be always (the default), never, or auto.
540 Turn off branch colors, even when the configuration file gives the
541 default to color output.
542 Same as
<tt>--color=never
</tt>.
550 List or delete (if used with -d) the remote-tracking branches.
558 List both remote-tracking branches and local branches.
569 Show sha1 and commit subject line for each head, along with
570 relationship to upstream branch (if any). If given twice, print
571 the name of the upstream branch, as well.
575 --abbrev=
<length
>
579 Alter the sha1
’s minimum display length in the output listing.
580 The default value is
7.
588 Display the full sha1s in the output listing rather than abbreviating them.
599 When creating a new branch, set up configuration to mark the
600 start-point branch as
"upstream" from the new branch. This
601 configuration will tell git to show the relationship between the
602 two branches in
<tt>git status
</tt> and
<tt>git branch -v
</tt>. Furthermore,
603 it directs
<tt>git pull
</tt> without arguments to pull from the
604 upstream when the new branch is checked out.
606 <div class=
"paragraph"><p>This behavior is the default when the start point is a remote-tracking branch.
607 Set the branch.autosetupmerge configuration variable to
<tt>false
</tt> if you
608 want
<tt>git checkout
</tt> and
<tt>git branch
</tt> to always behave as if
<em>--no-track
</em>
609 were given. Set it to
<tt>always
</tt> if you want this behavior when the
610 start-point is either a local or remote-tracking branch.
</p></div>
617 Do not set up
"upstream" configuration, even if the
618 branch.autosetupmerge configuration variable is true.
626 If specified branch does not exist yet or if
<em>--force
</em> has been
627 given, acts exactly like
<em>--track
</em>. Otherwise sets up configuration
628 like
<em>--track
</em> would when creating the branch, except that where
629 branch points to is not changed.
633 --contains
<commit
>
637 Only list branches which contain the specified commit.
641 --merged [
<commit
>]
645 Only list branches whose tips are reachable from the
646 specified commit (HEAD if not specified).
650 --no-merged [
<commit
>]
654 Only list branches whose tips are not reachable from the
655 specified commit (HEAD if not specified).
663 The name of the branch to create or delete.
664 The new branch name must pass all checks defined by
665 <a href=
"git-check-ref-format.html">git-check-ref-format(
1)
</a>. Some of these checks
666 may restrict the characters allowed in a branch name.
674 The new branch head will point to this commit. It may be
675 given as a branch name, a commit-id, or a tag. If this
676 option is omitted, the current HEAD will be used instead.
684 The name of an existing branch to rename.
692 The new name for an existing branch. The same restrictions as for
693 <branchname
> apply.
698 <h2 id=
"_examples">Examples
</h2>
699 <div class=
"sectionbody">
700 <div class=
"dlist"><dl>
702 Start development from a known tag
705 <div class=
"listingblock">
706 <div class=
"content">
707 <pre><tt>$ git clone git://git.kernel.org/pub/scm/.../linux-
2.6 my2.6
709 $ git branch my2.6
.14 v2.6
.14 <b><1></b>
710 $ git checkout my2.6
.14</tt></pre>
712 <div class=
"colist arabic"><ol>
715 This step and the next one could be combined into a single step with
716 "checkout -b my2.6.14 v2.6.14".
722 Delete an unneeded branch
725 <div class=
"listingblock">
726 <div class=
"content">
727 <pre><tt>$ git clone git://git.kernel.org/.../git.git my.git
729 $ git branch -d -r origin/todo origin/html origin/man
<b><1></b>
730 $ git branch -D test
<b><2></b></tt></pre>
732 <div class=
"colist arabic"><ol>
735 Delete the remote-tracking branches
"todo",
"html" and
"man". The next
736 <em>fetch
</em> or
<em>pull
</em> will create them again unless you configure them not to.
737 See
<a href=
"git-fetch.html">git-fetch(
1)
</a>.
742 Delete the
"test" branch even if the
"master" branch (or whichever branch
743 is currently checked out) does not have all commits from the test branch.
750 <h2 id=
"_notes">Notes
</h2>
751 <div class=
"sectionbody">
752 <div class=
"paragraph"><p>If you are creating a branch that you want to checkout immediately, it is
753 easier to use the git checkout command with its
<tt>-b
</tt> option to create
754 a branch and check it out with a single command.
</p></div>
755 <div class=
"paragraph"><p>The options
<tt>--contains
</tt>,
<tt>--merged
</tt> and
<tt>--no-merged
</tt> serve three related
756 but different purposes:
</p></div>
757 <div class=
"ulist"><ul>
760 <tt>--contains
<commit
></tt> is used to find all branches which will need
761 special attention if
<commit
> were to be rebased or amended, since those
762 branches contain the specified
<commit
>.
767 <tt>--merged
</tt> is used to find all branches which can be safely deleted,
768 since those branches are fully contained by HEAD.
773 <tt>--no-merged
</tt> is used to find branches which are candidates for merging
774 into HEAD, since those branches are not fully contained by HEAD.
779 <h2 id=
"_see_also">SEE ALSO
</h2>
780 <div class=
"sectionbody">
781 <div class=
"paragraph"><p><a href=
"git-check-ref-format.html">git-check-ref-format(
1)
</a>,
782 <a href=
"git-fetch.html">git-fetch(
1)
</a>,
783 <a href=
"git-remote.html">git-remote(
1)
</a>,
784 <a href=
"user-manual.html#what-is-a-branch">“Understanding history: What is
785 a branch?
”</a> in the Git User
’s Manual.
</p></div>
787 <h2 id=
"_author">Author
</h2>
788 <div class=
"sectionbody">
789 <div class=
"paragraph"><p>Written by Linus Torvalds
<<a href=
"mailto:torvalds@osdl.org">torvalds@osdl.org
</a>> and Junio C Hamano
<<a href=
"mailto:gitster@pobox.com">gitster@pobox.com
</a>></p></div>
791 <h2 id=
"_documentation">Documentation
</h2>
792 <div class=
"sectionbody">
793 <div class=
"paragraph"><p>Documentation by Junio C Hamano and the git-list
<<a href=
"mailto:git@vger.kernel.org">git@vger.kernel.org
</a>>.
</p></div>
795 <h2 id=
"_git">GIT
</h2>
796 <div class=
"sectionbody">
797 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
800 <div id=
"footer-text">
801 Last updated
2010-
11-
25 03:
13:
40 UTC