Autogenerated HTML docs for v1.7.0.3-254-g4503b
[git/jnareb-git.git] / git-branch.html
blobf4bcccfc4178d6ebf5b577bf838733eb07faca38
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">
4 <head>
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">
8 /* Debug borders */
9 p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
11 border: 1px solid red;
15 body {
16 margin: 1em 5% 1em 5%;
19 a {
20 color: blue;
21 text-decoration: underline;
23 a:visited {
24 color: fuchsia;
27 em {
28 font-style: italic;
31 strong {
32 font-weight: bold;
35 tt {
36 color: navy;
39 h1, h2, h3, h4, h5, h6 {
40 color: #527bbd;
41 font-family: sans-serif;
42 margin-top: 1.2em;
43 margin-bottom: 0.5em;
44 line-height: 1.3;
47 h1, h2, h3 {
48 border-bottom: 2px solid silver;
50 h2 {
51 padding-top: 0.5em;
53 h3 {
54 float: left;
56 h3 + * {
57 clear: left;
60 div.sectionbody {
61 font-family: serif;
62 margin-left: 0;
65 hr {
66 border: 1px solid silver;
69 p {
70 margin-top: 0.5em;
71 margin-bottom: 0.5em;
74 pre {
75 padding: 0;
76 margin: 0;
79 span#author {
80 color: #527bbd;
81 font-family: sans-serif;
82 font-weight: bold;
83 font-size: 1.1em;
85 span#email {
87 span#revision {
88 font-family: sans-serif;
91 div#footer {
92 font-family: sans-serif;
93 font-size: small;
94 border-top: 2px solid silver;
95 padding-top: 0.5em;
96 margin-top: 4.0em;
98 div#footer-text {
99 float: left;
100 padding-bottom: 0.5em;
102 div#footer-badges {
103 float: right;
104 padding-bottom: 0.5em;
107 div#preamble,
108 div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
109 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
110 div.admonitionblock {
111 margin-right: 10%;
112 margin-top: 1.5em;
113 margin-bottom: 1.5em;
115 div.admonitionblock {
116 margin-top: 2.5em;
117 margin-bottom: 2.5em;
120 div.content { /* Block element content. */
121 padding: 0;
124 /* Block element titles. */
125 div.title, caption.title {
126 font-family: sans-serif;
127 font-weight: bold;
128 text-align: left;
129 margin-top: 1.0em;
130 margin-bottom: 0.5em;
132 div.title + * {
133 margin-top: 0;
136 td div.title:first-child {
137 margin-top: 0.0em;
139 div.content div.title:first-child {
140 margin-top: 0.0em;
142 div.content + div.title {
143 margin-top: 0.0em;
146 div.sidebarblock > div.content {
147 background: #ffffee;
148 border: 1px solid silver;
149 padding: 0.5em;
152 div.listingblock {
153 margin-right: 0%;
155 div.listingblock > div.content {
156 border: 1px solid silver;
157 background: #f4f4f4;
158 padding: 0.5em;
161 div.quoteblock > div.content {
162 padding-left: 2.0em;
165 div.attribution {
166 text-align: right;
168 div.verseblock + div.attribution {
169 text-align: left;
172 div.admonitionblock .icon {
173 vertical-align: top;
174 font-size: 1.1em;
175 font-weight: bold;
176 text-decoration: underline;
177 color: #527bbd;
178 padding-right: 0.5em;
180 div.admonitionblock td.content {
181 padding-left: 0.5em;
182 border-left: 2px solid silver;
185 div.exampleblock > div.content {
186 border-left: 2px solid silver;
187 padding: 0.5em;
190 div.verseblock div.content {
191 white-space: pre;
194 div.imageblock div.content { padding-left: 0; }
195 div.imageblock img { border: 1px solid silver; }
196 span.image img { border-style: none; }
198 dl {
199 margin-top: 0.8em;
200 margin-bottom: 0.8em;
202 dt {
203 margin-top: 0.5em;
204 margin-bottom: 0;
205 font-style: italic;
207 dd > *:first-child {
208 margin-top: 0;
211 ul, ol {
212 list-style-position: outside;
214 div.olist2 ol {
215 list-style-type: lower-alpha;
218 div.tableblock > table {
219 border: 3px solid #527bbd;
221 thead {
222 font-family: sans-serif;
223 font-weight: bold;
225 tfoot {
226 font-weight: bold;
229 div.hlist {
230 margin-top: 0.8em;
231 margin-bottom: 0.8em;
233 div.hlist td {
234 padding-bottom: 5px;
236 td.hlist1 {
237 vertical-align: top;
238 font-style: italic;
239 padding-right: 0.8em;
241 td.hlist2 {
242 vertical-align: top;
245 @media print {
246 div#footer-badges { display: none; }
249 div#toctitle {
250 color: #527bbd;
251 font-family: sans-serif;
252 font-size: 1.1em;
253 font-weight: bold;
254 margin-top: 1.0em;
255 margin-bottom: 0.1em;
258 div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
259 margin-top: 0;
260 margin-bottom: 0;
262 div.toclevel2 {
263 margin-left: 2em;
264 font-size: 0.9em;
266 div.toclevel3 {
267 margin-left: 4em;
268 font-size: 0.9em;
270 div.toclevel4 {
271 margin-left: 6em;
272 font-size: 0.9em;
274 include1::./stylesheets/xhtml11-manpage.css[]
275 /* Workarounds for IE6's broken and incomplete CSS2. */
277 div.sidebar-content {
278 background: #ffffee;
279 border: 1px solid silver;
280 padding: 0.5em;
282 div.sidebar-title, div.image-title {
283 font-family: sans-serif;
284 font-weight: bold;
285 margin-top: 0.0em;
286 margin-bottom: 0.5em;
289 div.listingblock div.content {
290 border: 1px solid silver;
291 background: #f4f4f4;
292 padding: 0.5em;
295 div.quoteblock-content {
296 padding-left: 2.0em;
299 div.exampleblock-content {
300 border-left: 2px solid silver;
301 padding-left: 0.5em;
304 /* IE6 sets dynamically generated links as visited. */
305 div#toc a:visited { color: blue; }
306 </style>
307 <title>git-branch(1)</title>
308 </head>
309 <body>
310 <div id="header">
311 <h1>
312 git-branch(1) Manual Page
313 </h1>
314 <h2>NAME</h2>
315 <div class="sectionbody">
316 <p>git-branch -
317 List, create, or delete branches
318 </p>
319 </div>
320 </div>
321 <h2>SYNOPSIS</h2>
322 <div class="sectionbody">
323 <div class="verseblock">
324 <div class="content"><em>git branch</em> [--color[=&lt;when&gt;] | --no-color] [-r | -a]
325 [-v [--abbrev=&lt;length&gt; | --no-abbrev]]
326 [(--merged | --no-merged | --contains) [&lt;commit&gt;]]
327 <em>git branch</em> [--set-upstream | --track | --no-track] [-l] [-f] &lt;branchname&gt; [&lt;start-point&gt;]
328 <em>git branch</em> (-m | -M) [&lt;oldbranch&gt;] &lt;newbranch&gt;
329 <em>git branch</em> (-d | -D) [-r] &lt;branchname&gt;&#8230;</div></div>
330 </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 &lt;commit&gt; 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 &lt;branchname&gt;
344 which points to the current <em>HEAD</em>, or &lt;start-point&gt; 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 &lt;newbranch&gt;" 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, &lt;oldbranch&gt; will be renamed to &lt;newbranch&gt;.
354 If &lt;oldbranch&gt; had a corresponding reflog, it is renamed to match
355 &lt;newbranch&gt;, and a reflog entry is created to remember the branch
356 renaming. If &lt;newbranch&gt; exists, -M must be used to force the rename
357 to happen.</p></div>
358 <div class="para"><p>With a <tt>-d</tt> or <tt>-D</tt> option, <tt>&lt;branchname&gt;</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>
366 </div>
367 <h2 id="_options">OPTIONS</h2>
368 <div class="sectionbody">
369 <div class="vlist"><dl>
370 <dt>
372 </dt>
373 <dd>
375 Delete a branch. The branch must be fully merged in HEAD.
376 </p>
377 </dd>
378 <dt>
380 </dt>
381 <dd>
383 Delete a branch irrespective of its merged status.
384 </p>
385 </dd>
386 <dt>
388 </dt>
389 <dd>
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 "&lt;branchname&gt;@{yesterday}".
394 </p>
395 </dd>
396 <dt>
398 </dt>
399 <dt>
400 --force
401 </dt>
402 <dd>
404 Reset &lt;branchname&gt; to &lt;startpoint&gt; if &lt;branchname&gt; exists
405 already. Without <tt>-f</tt> <em>git branch</em> refuses to change an existing branch.
406 </p>
407 </dd>
408 <dt>
410 </dt>
411 <dd>
413 Move/rename a branch and the corresponding reflog.
414 </p>
415 </dd>
416 <dt>
418 </dt>
419 <dd>
421 Move/rename a branch even if the new branch name already exists.
422 </p>
423 </dd>
424 <dt>
425 --color[=&lt;when&gt;]
426 </dt>
427 <dd>
429 Color branches to highlight current, local, and remote branches.
430 The value must be always (the default), never, or auto.
431 </p>
432 </dd>
433 <dt>
434 --no-color
435 </dt>
436 <dd>
438 Turn off branch colors, even when the configuration file gives the
439 default to color output.
440 Same as <tt>--color=never</tt>.
441 </p>
442 </dd>
443 <dt>
445 </dt>
446 <dd>
448 List or delete (if used with -d) the remote-tracking branches.
449 </p>
450 </dd>
451 <dt>
453 </dt>
454 <dd>
456 List both remote-tracking branches and local branches.
457 </p>
458 </dd>
459 <dt>
461 </dt>
462 <dt>
463 --verbose
464 </dt>
465 <dd>
467 Show sha1 and commit subject line for each head, along with
468 relationship to upstream branch (if any). If given twice, print
469 the name of the upstream branch, as well.
470 </p>
471 </dd>
472 <dt>
473 --abbrev=&lt;length&gt;
474 </dt>
475 <dd>
477 Alter the sha1's minimum display length in the output listing.
478 The default value is 7.
479 </p>
480 </dd>
481 <dt>
482 --no-abbrev
483 </dt>
484 <dd>
486 Display the full sha1s in the output listing rather than abbreviating them.
487 </p>
488 </dd>
489 <dt>
491 </dt>
492 <dt>
493 --track
494 </dt>
495 <dd>
497 When creating a new branch, set up configuration to mark the
498 start-point branch as "upstream" from the new branch. This
499 configuration will tell git to show the relationship between the
500 two branches in <tt>git status</tt> and <tt>git branch -v</tt>. Furthermore,
501 it directs <tt>git pull</tt> without arguments to pull from the
502 upstream when the new branch is checked out.
503 </p>
504 <div class="para"><p>This behavior is the default when the start point is a remote branch.
505 Set the branch.autosetupmerge configuration variable to <tt>false</tt> if you
506 want <tt>git checkout</tt> and <tt>git branch</tt> to always behave as if <em>--no-track</em>
507 were given. Set it to <tt>always</tt> if you want this behavior when the
508 start-point is either a local or remote branch.</p></div>
509 </dd>
510 <dt>
511 --no-track
512 </dt>
513 <dd>
515 Do not set up "upstream" configuration, even if the
516 branch.autosetupmerge configuration variable is true.
517 </p>
518 </dd>
519 <dt>
520 --set-upstream
521 </dt>
522 <dd>
524 If specified branch does not exist yet or if <em>--force</em> has been
525 given, acts exactly like <em>--track</em>. Otherwise sets up configuration
526 like <em>--track</em> would when creating the branch, except that where
527 branch points to is not changed.
528 </p>
529 </dd>
530 <dt>
531 --contains &lt;commit&gt;
532 </dt>
533 <dd>
535 Only list branches which contain the specified commit.
536 </p>
537 </dd>
538 <dt>
539 --merged [&lt;commit&gt;]
540 </dt>
541 <dd>
543 Only list branches whose tips are reachable from the
544 specified commit (HEAD if not specified).
545 </p>
546 </dd>
547 <dt>
548 --no-merged [&lt;commit&gt;]
549 </dt>
550 <dd>
552 Only list branches whose tips are not reachable from the
553 specified commit (HEAD if not specified).
554 </p>
555 </dd>
556 <dt>
557 &lt;branchname&gt;
558 </dt>
559 <dd>
561 The name of the branch to create or delete.
562 The new branch name must pass all checks defined by
563 <a href="git-check-ref-format.html">git-check-ref-format(1)</a>. Some of these checks
564 may restrict the characters allowed in a branch name.
565 </p>
566 </dd>
567 <dt>
568 &lt;start-point&gt;
569 </dt>
570 <dd>
572 The new branch head will point to this commit. It may be
573 given as a branch name, a commit-id, or a tag. If this
574 option is omitted, the current HEAD will be used instead.
575 </p>
576 </dd>
577 <dt>
578 &lt;oldbranch&gt;
579 </dt>
580 <dd>
582 The name of an existing branch to rename.
583 </p>
584 </dd>
585 <dt>
586 &lt;newbranch&gt;
587 </dt>
588 <dd>
590 The new name for an existing branch. The same restrictions as for
591 &lt;branchname&gt; apply.
592 </p>
593 </dd>
594 </dl></div>
595 </div>
596 <h2 id="_examples">Examples</h2>
597 <div class="sectionbody">
598 <div class="vlist"><dl>
599 <dt>
600 Start development from a known tag
601 </dt>
602 <dd>
603 <div class="listingblock">
604 <div class="content">
605 <pre><tt>$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
606 $ cd my2.6
607 $ git branch my2.6.14 v2.6.14 <b>(1)</b>
608 $ git checkout my2.6.14</tt></pre>
609 </div></div>
610 <div class="colist"><ol>
611 <li>
613 This step and the next one could be combined into a single step with
614 "checkout -b my2.6.14 v2.6.14".
615 </p>
616 </li>
617 </ol></div>
618 </dd>
619 <dt>
620 Delete an unneeded branch
621 </dt>
622 <dd>
623 <div class="listingblock">
624 <div class="content">
625 <pre><tt>$ git clone git://git.kernel.org/.../git.git my.git
626 $ cd my.git
627 $ git branch -d -r origin/todo origin/html origin/man <b>(1)</b>
628 $ git branch -D test <b>(2)</b></tt></pre>
629 </div></div>
630 <div class="colist"><ol>
631 <li>
633 Delete the remote-tracking branches "todo", "html" and "man". The next
634 <em>fetch</em> or <em>pull</em> will create them again unless you configure them not to.
635 See <a href="git-fetch.html">git-fetch(1)</a>.
636 </p>
637 </li>
638 <li>
640 Delete the "test" branch even if the "master" branch (or whichever branch
641 is currently checked out) does not have all commits from the test branch.
642 </p>
643 </li>
644 </ol></div>
645 </dd>
646 </dl></div>
647 </div>
648 <h2 id="_notes">Notes</h2>
649 <div class="sectionbody">
650 <div class="para"><p>If you are creating a branch that you want to checkout immediately, it is
651 easier to use the git checkout command with its <tt>-b</tt> option to create
652 a branch and check it out with a single command.</p></div>
653 <div class="para"><p>The options <tt>--contains</tt>, <tt>--merged</tt> and <tt>--no-merged</tt> serve three related
654 but different purposes:</p></div>
655 <div class="ilist"><ul>
656 <li>
658 <tt>--contains &lt;commit&gt;</tt> is used to find all branches which will need
659 special attention if &lt;commit&gt; were to be rebased or amended, since those
660 branches contain the specified &lt;commit&gt;.
661 </p>
662 </li>
663 <li>
665 <tt>--merged</tt> is used to find all branches which can be safely deleted,
666 since those branches are fully contained by HEAD.
667 </p>
668 </li>
669 <li>
671 <tt>--no-merged</tt> is used to find branches which are candidates for merging
672 into HEAD, since those branches are not fully contained by HEAD.
673 </p>
674 </li>
675 </ul></div>
676 </div>
677 <h2 id="_see_also">SEE ALSO</h2>
678 <div class="sectionbody">
679 <div class="para"><p><a href="git-check-ref-format.html">git-check-ref-format(1)</a>,
680 <a href="git-fetch.html">git-fetch(1)</a>,
681 <a href="git-remote.html">git-remote(1)</a>,
682 <a href="user-manual.html#what-is-a-branch">&#8220;Understanding history: What is
683 a branch?&#8221;</a> in the Git User's Manual.</p></div>
684 </div>
685 <h2 id="_author">Author</h2>
686 <div class="sectionbody">
687 <div class="para"><p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt; and Junio C Hamano &lt;gitster@pobox.com&gt;</p></div>
688 </div>
689 <h2 id="_documentation">Documentation</h2>
690 <div class="sectionbody">
691 <div class="para"><p>Documentation by Junio C Hamano and the git-list &lt;git@vger.kernel.org&gt;.</p></div>
692 </div>
693 <h2 id="_git">GIT</h2>
694 <div class="sectionbody">
695 <div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
696 </div>
697 <div id="footer">
698 <div id="footer-text">
699 Last updated 2010-03-03 05:12:39 UTC
700 </div>
701 </div>
702 </body>
703 </html>