Autogenerated HTML docs for v1.6.6-35-g1d85d
[git/jnareb-git.git] / git-branch.html
blob1d918788b57159f6b83d298354c2c650193785e9
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 | --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> [--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
426 </dt>
427 <dd>
429 Color branches to highlight current, local, and remote branches.
430 </p>
431 </dd>
432 <dt>
433 --no-color
434 </dt>
435 <dd>
437 Turn off branch colors, even when the configuration file gives the
438 default to color output.
439 </p>
440 </dd>
441 <dt>
443 </dt>
444 <dd>
446 List or delete (if used with -d) the remote-tracking branches.
447 </p>
448 </dd>
449 <dt>
451 </dt>
452 <dd>
454 List both remote-tracking branches and local branches.
455 </p>
456 </dd>
457 <dt>
459 </dt>
460 <dt>
461 --verbose
462 </dt>
463 <dd>
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.
468 </p>
469 </dd>
470 <dt>
471 --abbrev=&lt;length&gt;
472 </dt>
473 <dd>
475 Alter the sha1's minimum display length in the output listing.
476 The default value is 7.
477 </p>
478 </dd>
479 <dt>
480 --no-abbrev
481 </dt>
482 <dd>
484 Display the full sha1s in the output listing rather than abbreviating them.
485 </p>
486 </dd>
487 <dt>
489 </dt>
490 <dt>
491 --track
492 </dt>
493 <dd>
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.
501 </p>
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>
507 </dd>
508 <dt>
509 --no-track
510 </dt>
511 <dd>
513 Do not set up "upstream" configuration, even if the
514 branch.autosetupmerge configuration variable is true.
515 </p>
516 </dd>
517 <dt>
518 --contains &lt;commit&gt;
519 </dt>
520 <dd>
522 Only list branches which contain the specified commit.
523 </p>
524 </dd>
525 <dt>
526 --merged [&lt;commit&gt;]
527 </dt>
528 <dd>
530 Only list branches whose tips are reachable from the
531 specified commit (HEAD if not specified).
532 </p>
533 </dd>
534 <dt>
535 --no-merged [&lt;commit&gt;]
536 </dt>
537 <dd>
539 Only list branches whose tips are not reachable from the
540 specified commit (HEAD if not specified).
541 </p>
542 </dd>
543 <dt>
544 &lt;branchname&gt;
545 </dt>
546 <dd>
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.
552 </p>
553 </dd>
554 <dt>
555 &lt;start-point&gt;
556 </dt>
557 <dd>
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.
562 </p>
563 </dd>
564 <dt>
565 &lt;oldbranch&gt;
566 </dt>
567 <dd>
569 The name of an existing branch to rename.
570 </p>
571 </dd>
572 <dt>
573 &lt;newbranch&gt;
574 </dt>
575 <dd>
577 The new name for an existing branch. The same restrictions as for
578 &lt;branchname&gt; apply.
579 </p>
580 </dd>
581 </dl></div>
582 </div>
583 <h2 id="_examples">Examples</h2>
584 <div class="sectionbody">
585 <div class="vlist"><dl>
586 <dt>
587 Start development from a known tag
588 </dt>
589 <dd>
590 <div class="listingblock">
591 <div class="content">
592 <pre><tt>$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
593 $ cd my2.6
594 $ git branch my2.6.14 v2.6.14 <b>(1)</b>
595 $ git checkout my2.6.14</tt></pre>
596 </div></div>
597 <div class="colist"><ol>
598 <li>
600 This step and the next one could be combined into a single step with
601 "checkout -b my2.6.14 v2.6.14".
602 </p>
603 </li>
604 </ol></div>
605 </dd>
606 <dt>
607 Delete an unneeded branch
608 </dt>
609 <dd>
610 <div class="listingblock">
611 <div class="content">
612 <pre><tt>$ git clone git://git.kernel.org/.../git.git my.git
613 $ cd 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>
616 </div></div>
617 <div class="colist"><ol>
618 <li>
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>.
623 </p>
624 </li>
625 <li>
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.
629 </p>
630 </li>
631 </ol></div>
632 </dd>
633 </dl></div>
634 </div>
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>
643 <li>
645 <tt>--contains &lt;commit&gt;</tt> is used to find all branches which will need
646 special attention if &lt;commit&gt; were to be rebased or amended, since those
647 branches contain the specified &lt;commit&gt;.
648 </p>
649 </li>
650 <li>
652 <tt>--merged</tt> is used to find all branches which can be safely deleted,
653 since those branches are fully contained by HEAD.
654 </p>
655 </li>
656 <li>
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.
660 </p>
661 </li>
662 </ul></div>
663 </div>
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">&#8220;Understanding history: What is
670 a branch?&#8221;</a> in the Git User's Manual.</p></div>
671 </div>
672 <h2 id="_author">Author</h2>
673 <div class="sectionbody">
674 <div class="para"><p>Written by Linus Torvalds &lt;torvalds@osdl.org&gt; and Junio C Hamano &lt;gitster@pobox.com&gt;</p></div>
675 </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 &lt;git@vger.kernel.org&gt;.</p></div>
679 </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>
683 </div>
684 <div id="footer">
685 <div id="footer-text">
686 Last updated 2009-12-03 09:12:27 UTC
687 </div>
688 </div>
689 </body>
690 </html>