Autogenerated HTML docs for v2.42.0-526-g3130c1
[git-htmldocs.git] / git-branch.html
blob33c7c65ccfd53ff6c89ae7fc260b4169b0c444fe
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
3 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
5 <head>
6 <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
7 <meta name="generator" content="AsciiDoc 10.2.0" />
8 <title>git-branch(1)</title>
9 <style type="text/css">
10 /* Shared CSS for AsciiDoc xhtml11 and html5 backends */
12 /* Default font. */
13 body {
14 font-family: Georgia,serif;
17 /* Title font. */
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
21 #toctitle,
22 #author, #revnumber, #revdate, #revremark,
23 #footer {
24 font-family: Arial,Helvetica,sans-serif;
27 body {
28 margin: 1em 5% 1em 5%;
31 a {
32 color: blue;
33 text-decoration: underline;
35 a:visited {
36 color: fuchsia;
39 em {
40 font-style: italic;
41 color: navy;
44 strong {
45 font-weight: bold;
46 color: #083194;
49 h1, h2, h3, h4, h5, h6 {
50 color: #527bbd;
51 margin-top: 1.2em;
52 margin-bottom: 0.5em;
53 line-height: 1.3;
56 h1, h2, h3 {
57 border-bottom: 2px solid silver;
59 h2 {
60 padding-top: 0.5em;
62 h3 {
63 float: left;
65 h3 + * {
66 clear: left;
68 h5 {
69 font-size: 1.0em;
72 div.sectionbody {
73 margin-left: 0;
76 hr {
77 border: 1px solid silver;
80 p {
81 margin-top: 0.5em;
82 margin-bottom: 0.5em;
85 ul, ol, li > p {
86 margin-top: 0;
88 ul > li { color: #aaa; }
89 ul > li > * { color: black; }
91 .monospaced, code, pre {
92 font-family: "Courier New", Courier, monospace;
93 font-size: inherit;
94 color: navy;
95 padding: 0;
96 margin: 0;
98 pre {
99 white-space: pre-wrap;
102 #author {
103 color: #527bbd;
104 font-weight: bold;
105 font-size: 1.1em;
107 #email {
109 #revnumber, #revdate, #revremark {
112 #footer {
113 font-size: small;
114 border-top: 2px solid silver;
115 padding-top: 0.5em;
116 margin-top: 4.0em;
118 #footer-text {
119 float: left;
120 padding-bottom: 0.5em;
122 #footer-badges {
123 float: right;
124 padding-bottom: 0.5em;
127 #preamble {
128 margin-top: 1.5em;
129 margin-bottom: 1.5em;
131 div.imageblock, div.exampleblock, div.verseblock,
132 div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
133 div.admonitionblock {
134 margin-top: 1.0em;
135 margin-bottom: 1.5em;
137 div.admonitionblock {
138 margin-top: 2.0em;
139 margin-bottom: 2.0em;
140 margin-right: 10%;
141 color: #606060;
144 div.content { /* Block element content. */
145 padding: 0;
148 /* Block element titles. */
149 div.title, caption.title {
150 color: #527bbd;
151 font-weight: bold;
152 text-align: left;
153 margin-top: 1.0em;
154 margin-bottom: 0.5em;
156 div.title + * {
157 margin-top: 0;
160 td div.title:first-child {
161 margin-top: 0.0em;
163 div.content div.title:first-child {
164 margin-top: 0.0em;
166 div.content + div.title {
167 margin-top: 0.0em;
170 div.sidebarblock > div.content {
171 background: #ffffee;
172 border: 1px solid #dddddd;
173 border-left: 4px solid #f0f0f0;
174 padding: 0.5em;
177 div.listingblock > div.content {
178 border: 1px solid #dddddd;
179 border-left: 5px solid #f0f0f0;
180 background: #f8f8f8;
181 padding: 0.5em;
184 div.quoteblock, div.verseblock {
185 padding-left: 1.0em;
186 margin-left: 1.0em;
187 margin-right: 10%;
188 border-left: 5px solid #f0f0f0;
189 color: #888;
192 div.quoteblock > div.attribution {
193 padding-top: 0.5em;
194 text-align: right;
197 div.verseblock > pre.content {
198 font-family: inherit;
199 font-size: inherit;
201 div.verseblock > div.attribution {
202 padding-top: 0.75em;
203 text-align: left;
205 /* DEPRECATED: Pre version 8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
207 text-align: left;
210 div.admonitionblock .icon {
211 vertical-align: top;
212 font-size: 1.1em;
213 font-weight: bold;
214 text-decoration: underline;
215 color: #527bbd;
216 padding-right: 0.5em;
218 div.admonitionblock td.content {
219 padding-left: 0.5em;
220 border-left: 3px solid #dddddd;
223 div.exampleblock > div.content {
224 border-left: 3px solid #dddddd;
225 padding-left: 0.5em;
228 div.imageblock div.content { padding-left: 0; }
229 span.image img { border-style: none; vertical-align: text-bottom; }
230 a.image:visited { color: white; }
232 dl {
233 margin-top: 0.8em;
234 margin-bottom: 0.8em;
236 dt {
237 margin-top: 0.5em;
238 margin-bottom: 0;
239 font-style: normal;
240 color: navy;
242 dd > *:first-child {
243 margin-top: 0.1em;
246 ul, ol {
247 list-style-position: outside;
249 ol.arabic {
250 list-style-type: decimal;
252 ol.loweralpha {
253 list-style-type: lower-alpha;
255 ol.upperalpha {
256 list-style-type: upper-alpha;
258 ol.lowerroman {
259 list-style-type: lower-roman;
261 ol.upperroman {
262 list-style-type: upper-roman;
265 div.compact ul, div.compact ol,
266 div.compact p, div.compact p,
267 div.compact div, div.compact div {
268 margin-top: 0.1em;
269 margin-bottom: 0.1em;
272 tfoot {
273 font-weight: bold;
275 td > div.verse {
276 white-space: pre;
279 div.hdlist {
280 margin-top: 0.8em;
281 margin-bottom: 0.8em;
283 div.hdlist tr {
284 padding-bottom: 15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
287 font-weight: bold;
289 td.hdlist1 {
290 vertical-align: top;
291 font-style: normal;
292 padding-right: 0.8em;
293 color: navy;
295 td.hdlist2 {
296 vertical-align: top;
298 div.hdlist.compact tr {
299 margin: 0;
300 padding-bottom: 0;
303 .comment {
304 background: yellow;
307 .footnote, .footnoteref {
308 font-size: 0.8em;
311 span.footnote, span.footnoteref {
312 vertical-align: super;
315 #footnotes {
316 margin: 20px 0 20px 0;
317 padding: 7px 0 0 0;
320 #footnotes div.footnote {
321 margin: 0 0 5px 0;
324 #footnotes hr {
325 border: none;
326 border-top: 1px solid silver;
327 height: 1px;
328 text-align: left;
329 margin-left: 0;
330 width: 20%;
331 min-width: 100px;
334 div.colist td {
335 padding-right: 0.5em;
336 padding-bottom: 0.3em;
337 vertical-align: top;
339 div.colist td img {
340 margin-top: 0.3em;
343 @media print {
344 #footer-badges { display: none; }
347 #toc {
348 margin-bottom: 2.5em;
351 #toctitle {
352 color: #527bbd;
353 font-size: 1.1em;
354 font-weight: bold;
355 margin-top: 1.0em;
356 margin-bottom: 0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
360 margin-top: 0;
361 margin-bottom: 0;
363 div.toclevel2 {
364 margin-left: 2em;
365 font-size: 0.9em;
367 div.toclevel3 {
368 margin-left: 4em;
369 font-size: 0.9em;
371 div.toclevel4 {
372 margin-left: 6em;
373 font-size: 0.9em;
376 span.aqua { color: aqua; }
377 span.black { color: black; }
378 span.blue { color: blue; }
379 span.fuchsia { color: fuchsia; }
380 span.gray { color: gray; }
381 span.green { color: green; }
382 span.lime { color: lime; }
383 span.maroon { color: maroon; }
384 span.navy { color: navy; }
385 span.olive { color: olive; }
386 span.purple { color: purple; }
387 span.red { color: red; }
388 span.silver { color: silver; }
389 span.teal { color: teal; }
390 span.white { color: white; }
391 span.yellow { color: yellow; }
393 span.aqua-background { background: aqua; }
394 span.black-background { background: black; }
395 span.blue-background { background: blue; }
396 span.fuchsia-background { background: fuchsia; }
397 span.gray-background { background: gray; }
398 span.green-background { background: green; }
399 span.lime-background { background: lime; }
400 span.maroon-background { background: maroon; }
401 span.navy-background { background: navy; }
402 span.olive-background { background: olive; }
403 span.purple-background { background: purple; }
404 span.red-background { background: red; }
405 span.silver-background { background: silver; }
406 span.teal-background { background: teal; }
407 span.white-background { background: white; }
408 span.yellow-background { background: yellow; }
410 span.big { font-size: 2em; }
411 span.small { font-size: 0.6em; }
413 span.underline { text-decoration: underline; }
414 span.overline { text-decoration: overline; }
415 span.line-through { text-decoration: line-through; }
417 div.unbreakable { page-break-inside: avoid; }
421 * xhtml11 specific
423 * */
425 div.tableblock {
426 margin-top: 1.0em;
427 margin-bottom: 1.5em;
429 div.tableblock > table {
430 border: 3px solid #527bbd;
432 thead, p.table.header {
433 font-weight: bold;
434 color: #527bbd;
436 p.table {
437 margin-top: 0;
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock > table[frame="void"] {
441 border-style: none;
443 div.tableblock > table[frame="hsides"] {
444 border-left-style: none;
445 border-right-style: none;
447 div.tableblock > table[frame="vsides"] {
448 border-top-style: none;
449 border-bottom-style: none;
454 * html5 specific
456 * */
458 table.tableblock {
459 margin-top: 1.0em;
460 margin-bottom: 1.5em;
462 thead, p.tableblock.header {
463 font-weight: bold;
464 color: #527bbd;
466 p.tableblock {
467 margin-top: 0;
469 table.tableblock {
470 border-width: 3px;
471 border-spacing: 0px;
472 border-style: solid;
473 border-color: #527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
477 border-width: 1px;
478 padding: 4px;
479 border-style: solid;
480 border-color: #527bbd;
483 table.tableblock.frame-topbot {
484 border-left-style: hidden;
485 border-right-style: hidden;
487 table.tableblock.frame-sides {
488 border-top-style: hidden;
489 border-bottom-style: hidden;
491 table.tableblock.frame-none {
492 border-style: hidden;
495 th.tableblock.halign-left, td.tableblock.halign-left {
496 text-align: left;
498 th.tableblock.halign-center, td.tableblock.halign-center {
499 text-align: center;
501 th.tableblock.halign-right, td.tableblock.halign-right {
502 text-align: right;
505 th.tableblock.valign-top, td.tableblock.valign-top {
506 vertical-align: top;
508 th.tableblock.valign-middle, td.tableblock.valign-middle {
509 vertical-align: middle;
511 th.tableblock.valign-bottom, td.tableblock.valign-bottom {
512 vertical-align: bottom;
517 * manpage specific
519 * */
521 body.manpage h1 {
522 padding-top: 0.5em;
523 padding-bottom: 0.5em;
524 border-top: 2px solid silver;
525 border-bottom: 2px solid silver;
527 body.manpage h2 {
528 border-style: none;
530 body.manpage div.sectionbody {
531 margin-left: 3em;
534 @media print {
535 body.manpage div#toc { display: none; }
539 </style>
540 <script type="text/javascript">
541 /*<![CDATA[*/
542 var asciidoc = { // Namespace.
544 /////////////////////////////////////////////////////////////////////
545 // Table Of Contents generator
546 /////////////////////////////////////////////////////////////////////
548 /* Author: Mihai Bazon, September 2002
549 * http://students.infoiasi.ro/~mishoo
551 * Table Of Content generator
552 * Version: 0.4
554 * Feel free to use this script under the terms of the GNU General Public
555 * License, as long as you do not remove or alter this notice.
558 /* modified by Troy D. Hanson, September 2006. License: GPL */
559 /* modified by Stuart Rackham, 2006, 2009. License: GPL */
561 // toclevels = 1..4.
562 toc: function (toclevels) {
564 function getText(el) {
565 var text = "";
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
568 text += i.data;
569 else if (i.firstChild != null)
570 text += getText(i);
572 return text;
575 function TocEntry(el, text, toclevel) {
576 this.element = el;
577 this.text = text;
578 this.toclevel = toclevel;
581 function tocEntries(el, toclevels) {
582 var result = new Array;
583 var re = new RegExp('[hH]([1-'+(toclevels+1)+'])');
584 // Function that scans the DOM tree for header elements (the DOM2
585 // nodeIterator API would be a better technique but not supported by all
586 // browsers).
587 var iterate = function (el) {
588 for (var i = el.firstChild; i != null; i = i.nextSibling) {
589 if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
590 var mo = re.exec(i.tagName);
591 if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") {
592 result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
594 iterate(i);
598 iterate(el);
599 return result;
602 var toc = document.getElementById("toc");
603 if (!toc) {
604 return;
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
609 var i;
610 for (i = 0; i < toc.childNodes.length; i++) {
611 var entry = toc.childNodes[i];
612 if (entry.nodeName.toLowerCase() == 'div'
613 && entry.getAttribute("class")
614 && entry.getAttribute("class").match(/^toclevel/))
615 tocEntriesToRemove.push(entry);
617 for (i = 0; i < tocEntriesToRemove.length; i++) {
618 toc.removeChild(tocEntriesToRemove[i]);
621 // Rebuild TOC entries.
622 var entries = tocEntries(document.getElementById("content"), toclevels);
623 for (var i = 0; i < entries.length; ++i) {
624 var entry = entries[i];
625 if (entry.element.id == "")
626 entry.element.id = "_toc_" + i;
627 var a = document.createElement("a");
628 a.href = "#" + entry.element.id;
629 a.appendChild(document.createTextNode(entry.text));
630 var div = document.createElement("div");
631 div.appendChild(a);
632 div.className = "toclevel" + entry.toclevel;
633 toc.appendChild(div);
635 if (entries.length == 0)
636 toc.parentNode.removeChild(toc);
640 /////////////////////////////////////////////////////////////////////
641 // Footnotes generator
642 /////////////////////////////////////////////////////////////////////
644 /* Based on footnote generation code from:
645 * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html
648 footnotes: function () {
649 // Delete existing footnote entries in case we're reloading the footnodes.
650 var i;
651 var noteholder = document.getElementById("footnotes");
652 if (!noteholder) {
653 return;
655 var entriesToRemove = [];
656 for (i = 0; i < noteholder.childNodes.length; i++) {
657 var entry = noteholder.childNodes[i];
658 if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote")
659 entriesToRemove.push(entry);
661 for (i = 0; i < entriesToRemove.length; i++) {
662 noteholder.removeChild(entriesToRemove[i]);
665 // Rebuild footnote entries.
666 var cont = document.getElementById("content");
667 var spans = cont.getElementsByTagName("span");
668 var refs = {};
669 var n = 0;
670 for (i=0; i<spans.length; i++) {
671 if (spans[i].className == "footnote") {
672 n++;
673 var note = spans[i].getAttribute("data-note");
674 if (!note) {
675 // Use [\s\S] in place of . so multi-line matches work.
676 // Because JavaScript has no s (dotall) regex flag.
677 note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1];
678 spans[i].innerHTML =
679 "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n +
680 "' title='View footnote' class='footnote'>" + n + "</a>]";
681 spans[i].setAttribute("data-note", note);
683 noteholder.innerHTML +=
684 "<div class='footnote' id='_footnote_" + n + "'>" +
685 "<a href='#_footnoteref_" + n + "' title='Return to text'>" +
686 n + "</a>. " + note + "</div>";
687 var id =spans[i].getAttribute("id");
688 if (id != null) refs["#"+id] = n;
691 if (n == 0)
692 noteholder.parentNode.removeChild(noteholder);
693 else {
694 // Process footnoterefs.
695 for (i=0; i<spans.length; i++) {
696 if (spans[i].className == "footnoteref") {
697 var href = spans[i].getElementsByTagName("a")[0].getAttribute("href");
698 href = href.match(/#.*/)[0]; // Because IE return full URL.
699 n = refs[href];
700 spans[i].innerHTML =
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n + "</a>]";
708 install: function(toclevels) {
709 var timerId;
711 function reinstall() {
712 asciidoc.footnotes();
713 if (toclevels) {
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
720 reinstall();
723 timerId = setInterval(reinstall, 500);
724 if (document.addEventListener)
725 document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false);
726 else
727 window.onload = reinstallAndRemoveTimer;
731 asciidoc.install();
732 /*]]>*/
733 </script>
734 </head>
735 <body class="manpage">
736 <div id="header">
737 <h1>
738 git-branch(1) Manual Page
739 </h1>
740 <h2>NAME</h2>
741 <div class="sectionbody">
742 <p>git-branch -
743 List, create, or delete branches
744 </p>
745 </div>
746 </div>
747 <div id="content">
748 <div class="sect1">
749 <h2 id="_synopsis">SYNOPSIS</h2>
750 <div class="sectionbody">
751 <div class="verseblock">
752 <pre class="content"><em>git branch</em> [--color[=&lt;when&gt;] | --no-color] [--show-current]
753 [-v [--abbrev=&lt;n&gt; | --no-abbrev]]
754 [--column[=&lt;options&gt;] | --no-column] [--sort=&lt;key&gt;]
755 [--merged [&lt;commit&gt;]] [--no-merged [&lt;commit&gt;]]
756 [--contains [&lt;commit&gt;]] [--no-contains [&lt;commit&gt;]]
757 [--points-at &lt;object&gt;] [--format=&lt;format&gt;]
758 [(-r | --remotes) | (-a | --all)]
759 [--list] [&lt;pattern&gt;&#8230;]
760 <em>git branch</em> [--track[=(direct|inherit)] | --no-track] [-f]
761 [--recurse-submodules] &lt;branchname&gt; [&lt;start-point&gt;]
762 <em>git branch</em> (--set-upstream-to=&lt;upstream&gt; | -u &lt;upstream&gt;) [&lt;branchname&gt;]
763 <em>git branch</em> --unset-upstream [&lt;branchname&gt;]
764 <em>git branch</em> (-m | -M) [&lt;oldbranch&gt;] &lt;newbranch&gt;
765 <em>git branch</em> (-c | -C) [&lt;oldbranch&gt;] &lt;newbranch&gt;
766 <em>git branch</em> (-d | -D) [-r] &lt;branchname&gt;&#8230;
767 <em>git branch</em> --edit-description [&lt;branchname&gt;]</pre>
768 <div class="attribution">
769 </div></div>
770 </div>
771 </div>
772 <div class="sect1">
773 <h2 id="_description">DESCRIPTION</h2>
774 <div class="sectionbody">
775 <div class="paragraph"><p>If <code>--list</code> is given, or if there are no non-option arguments, existing
776 branches are listed; the current branch will be highlighted in green and
777 marked with an asterisk. Any branches checked out in linked worktrees will
778 be highlighted in cyan and marked with a plus sign. Option <code>-r</code> causes the
779 remote-tracking branches to be listed,
780 and option <code>-a</code> shows both local and remote branches.</p></div>
781 <div class="paragraph"><p>If a <code>&lt;pattern&gt;</code>
782 is given, it is used as a shell wildcard to restrict the output to
783 matching branches. If multiple patterns are given, a branch is shown if
784 it matches any of the patterns.</p></div>
785 <div class="paragraph"><p>Note that when providing a
786 <code>&lt;pattern&gt;</code>, you must use <code>--list</code>; otherwise the command may be interpreted
787 as branch creation.</p></div>
788 <div class="paragraph"><p>With <code>--contains</code>, shows only the branches that contain the named commit
789 (in other words, the branches whose tip commits are descendants of the
790 named commit), <code>--no-contains</code> inverts it. With <code>--merged</code>, only branches
791 merged into the named commit (i.e. the branches whose tip commits are
792 reachable from the named commit) will be listed. With <code>--no-merged</code> only
793 branches not merged into the named commit will be listed. If the &lt;commit&gt;
794 argument is missing it defaults to <code>HEAD</code> (i.e. the tip of the current
795 branch).</p></div>
796 <div class="paragraph"><p>The command&#8217;s second form creates a new branch head named &lt;branchname&gt;
797 which points to the current <code>HEAD</code>, or &lt;start-point&gt; if given. As a
798 special case, for &lt;start-point&gt;, you may use <code>"A...B"</code> as a shortcut for
799 the merge base of <code>A</code> and <code>B</code> if there is exactly one merge base. You
800 can leave out at most one of <code>A</code> and <code>B</code>, in which case it defaults to
801 <code>HEAD</code>.</p></div>
802 <div class="paragraph"><p>Note that this will create the new branch, but it will not switch the
803 working tree to it; use "git switch &lt;newbranch&gt;" to switch to the
804 new branch.</p></div>
805 <div class="paragraph"><p>When a local branch is started off a remote-tracking branch, Git sets up the
806 branch (specifically the <code>branch.&lt;name&gt;.remote</code> and <code>branch.&lt;name&gt;.merge</code>
807 configuration entries) so that <em>git pull</em> will appropriately merge from
808 the remote-tracking branch. This behavior may be changed via the global
809 <code>branch.autoSetupMerge</code> configuration flag. That setting can be
810 overridden by using the <code>--track</code> and <code>--no-track</code> options, and
811 changed later using <code>git branch --set-upstream-to</code>.</p></div>
812 <div class="paragraph"><p>With a <code>-m</code> or <code>-M</code> option, &lt;oldbranch&gt; will be renamed to &lt;newbranch&gt;.
813 If &lt;oldbranch&gt; had a corresponding reflog, it is renamed to match
814 &lt;newbranch&gt;, and a reflog entry is created to remember the branch
815 renaming. If &lt;newbranch&gt; exists, -M must be used to force the rename
816 to happen.</p></div>
817 <div class="paragraph"><p>The <code>-c</code> and <code>-C</code> options have the exact same semantics as <code>-m</code> and
818 <code>-M</code>, except instead of the branch being renamed, it will be copied to a
819 new name, along with its config and reflog.</p></div>
820 <div class="paragraph"><p>With a <code>-d</code> or <code>-D</code> option, <code>&lt;branchname&gt;</code> will be deleted. You may
821 specify more than one branch for deletion. If the branch currently
822 has a reflog then the reflog will also be deleted.</p></div>
823 <div class="paragraph"><p>Use <code>-r</code> together with <code>-d</code> to delete remote-tracking branches. Note, that it
824 only makes sense to delete remote-tracking branches if they no longer exist
825 in the remote repository or if <em>git fetch</em> was configured not to fetch
826 them again. See also the <em>prune</em> subcommand of <a href="git-remote.html">git-remote(1)</a> for a
827 way to clean up all obsolete remote-tracking branches.</p></div>
828 </div>
829 </div>
830 <div class="sect1">
831 <h2 id="_options">OPTIONS</h2>
832 <div class="sectionbody">
833 <div class="dlist"><dl>
834 <dt class="hdlist1">
836 </dt>
837 <dt class="hdlist1">
838 --delete
839 </dt>
840 <dd>
842 Delete a branch. The branch must be fully merged in its
843 upstream branch, or in <code>HEAD</code> if no upstream was set with
844 <code>--track</code> or <code>--set-upstream-to</code>.
845 </p>
846 </dd>
847 <dt class="hdlist1">
849 </dt>
850 <dd>
852 Shortcut for <code>--delete --force</code>.
853 </p>
854 </dd>
855 <dt class="hdlist1">
856 --create-reflog
857 </dt>
858 <dd>
860 Create the branch&#8217;s reflog. This activates recording of
861 all changes made to the branch ref, enabling use of date
862 based sha1 expressions such as "&lt;branchname&gt;@{yesterday}".
863 Note that in non-bare repositories, reflogs are usually
864 enabled by default by the <code>core.logAllRefUpdates</code> config option.
865 The negated form <code>--no-create-reflog</code> only overrides an earlier
866 <code>--create-reflog</code>, but currently does not negate the setting of
867 <code>core.logAllRefUpdates</code>.
868 </p>
869 </dd>
870 <dt class="hdlist1">
872 </dt>
873 <dt class="hdlist1">
874 --force
875 </dt>
876 <dd>
878 Reset &lt;branchname&gt; to &lt;start-point&gt;, even if &lt;branchname&gt; exists
879 already. Without <code>-f</code>, <em>git branch</em> refuses to change an existing branch.
880 In combination with <code>-d</code> (or <code>--delete</code>), allow deleting the
881 branch irrespective of its merged status, or whether it even
882 points to a valid commit. In combination with
883 <code>-m</code> (or <code>--move</code>), allow renaming the branch even if the new
884 branch name already exists, the same applies for <code>-c</code> (or <code>--copy</code>).
885 </p>
886 <div class="paragraph"><p>Note that <em>git branch -f &lt;branchname&gt; [&lt;start-point&gt;]</em>, even with <em>-f</em>,
887 refuses to change an existing branch <code>&lt;branchname&gt;</code> that is checked out
888 in another worktree linked to the same repository.</p></div>
889 </dd>
890 <dt class="hdlist1">
892 </dt>
893 <dt class="hdlist1">
894 --move
895 </dt>
896 <dd>
898 Move/rename a branch, together with its config and reflog.
899 </p>
900 </dd>
901 <dt class="hdlist1">
903 </dt>
904 <dd>
906 Shortcut for <code>--move --force</code>.
907 </p>
908 </dd>
909 <dt class="hdlist1">
911 </dt>
912 <dt class="hdlist1">
913 --copy
914 </dt>
915 <dd>
917 Copy a branch, together with its config and reflog.
918 </p>
919 </dd>
920 <dt class="hdlist1">
922 </dt>
923 <dd>
925 Shortcut for <code>--copy --force</code>.
926 </p>
927 </dd>
928 <dt class="hdlist1">
929 --color[=&lt;when&gt;]
930 </dt>
931 <dd>
933 Color branches to highlight current, local, and
934 remote-tracking branches.
935 The value must be always (the default), never, or auto.
936 </p>
937 </dd>
938 <dt class="hdlist1">
939 --no-color
940 </dt>
941 <dd>
943 Turn off branch colors, even when the configuration file gives the
944 default to color output.
945 Same as <code>--color=never</code>.
946 </p>
947 </dd>
948 <dt class="hdlist1">
950 </dt>
951 <dt class="hdlist1">
952 --ignore-case
953 </dt>
954 <dd>
956 Sorting and filtering branches are case insensitive.
957 </p>
958 </dd>
959 <dt class="hdlist1">
960 --omit-empty
961 </dt>
962 <dd>
964 Do not print a newline after formatted refs where the format expands
965 to the empty string.
966 </p>
967 </dd>
968 <dt class="hdlist1">
969 --column[=&lt;options&gt;]
970 </dt>
971 <dt class="hdlist1">
972 --no-column
973 </dt>
974 <dd>
976 Display branch listing in columns. See configuration variable
977 <code>column.branch</code> for option syntax. <code>--column</code> and <code>--no-column</code>
978 without options are equivalent to <em>always</em> and <em>never</em> respectively.
979 </p>
980 <div class="paragraph"><p>This option is only applicable in non-verbose mode.</p></div>
981 </dd>
982 <dt class="hdlist1">
984 </dt>
985 <dt class="hdlist1">
986 --remotes
987 </dt>
988 <dd>
990 List or delete (if used with -d) the remote-tracking branches.
991 Combine with <code>--list</code> to match the optional pattern(s).
992 </p>
993 </dd>
994 <dt class="hdlist1">
996 </dt>
997 <dt class="hdlist1">
998 --all
999 </dt>
1000 <dd>
1002 List both remote-tracking branches and local branches.
1003 Combine with <code>--list</code> to match optional pattern(s).
1004 </p>
1005 </dd>
1006 <dt class="hdlist1">
1008 </dt>
1009 <dt class="hdlist1">
1010 --list
1011 </dt>
1012 <dd>
1014 List branches. With optional <code>&lt;pattern&gt;...</code>, e.g. <code>git
1015 branch --list 'maint-*'</code>, list only the branches that match
1016 the pattern(s).
1017 </p>
1018 </dd>
1019 <dt class="hdlist1">
1020 --show-current
1021 </dt>
1022 <dd>
1024 Print the name of the current branch. In detached HEAD state,
1025 nothing is printed.
1026 </p>
1027 </dd>
1028 <dt class="hdlist1">
1030 </dt>
1031 <dt class="hdlist1">
1033 </dt>
1034 <dt class="hdlist1">
1035 --verbose
1036 </dt>
1037 <dd>
1039 When in list mode,
1040 show sha1 and commit subject line for each head, along with
1041 relationship to upstream branch (if any). If given twice, print
1042 the path of the linked worktree (if any) and the name of the upstream
1043 branch, as well (see also <code>git remote show &lt;remote&gt;</code>). Note that the
1044 current worktree&#8217;s HEAD will not have its path printed (it will always
1045 be your current directory).
1046 </p>
1047 </dd>
1048 <dt class="hdlist1">
1050 </dt>
1051 <dt class="hdlist1">
1052 --quiet
1053 </dt>
1054 <dd>
1056 Be more quiet when creating or deleting a branch, suppressing
1057 non-error messages.
1058 </p>
1059 </dd>
1060 <dt class="hdlist1">
1061 --abbrev=&lt;n&gt;
1062 </dt>
1063 <dd>
1065 In the verbose listing that show the commit object name,
1066 show the shortest prefix that is at least <em>&lt;n&gt;</em> hexdigits
1067 long that uniquely refers the object.
1068 The default value is 7 and can be overridden by the <code>core.abbrev</code>
1069 config option.
1070 </p>
1071 </dd>
1072 <dt class="hdlist1">
1073 --no-abbrev
1074 </dt>
1075 <dd>
1077 Display the full sha1s in the output listing rather than abbreviating them.
1078 </p>
1079 </dd>
1080 <dt class="hdlist1">
1082 </dt>
1083 <dt class="hdlist1">
1084 --track[=(direct|inherit)]
1085 </dt>
1086 <dd>
1088 When creating a new branch, set up <code>branch.&lt;name&gt;.remote</code> and
1089 <code>branch.&lt;name&gt;.merge</code> configuration entries to set "upstream" tracking
1090 configuration for the new branch. This
1091 configuration will tell git to show the relationship between the
1092 two branches in <code>git status</code> and <code>git branch -v</code>. Furthermore,
1093 it directs <code>git pull</code> without arguments to pull from the
1094 upstream when the new branch is checked out.
1095 </p>
1096 <div class="paragraph"><p>The exact upstream branch is chosen depending on the optional argument:
1097 <code>-t</code>, <code>--track</code>, or <code>--track=direct</code> means to use the start-point branch
1098 itself as the upstream; <code>--track=inherit</code> means to copy the upstream
1099 configuration of the start-point branch.</p></div>
1100 <div class="paragraph"><p>The branch.autoSetupMerge configuration variable specifies how <code>git switch</code>,
1101 <code>git checkout</code> and <code>git branch</code> should behave when neither <code>--track</code> nor
1102 <code>--no-track</code> are specified:</p></div>
1103 <div class="paragraph"><p>The default option, <code>true</code>, behaves as though <code>--track=direct</code>
1104 were given whenever the start-point is a remote-tracking branch.
1105 <code>false</code> behaves as if <code>--no-track</code> were given. <code>always</code> behaves as though
1106 <code>--track=direct</code> were given. <code>inherit</code> behaves as though <code>--track=inherit</code>
1107 were given. <code>simple</code> behaves as though <code>--track=direct</code> were given only when
1108 the start-point is a remote-tracking branch and the new branch has the same
1109 name as the remote branch.</p></div>
1110 <div class="paragraph"><p>See <a href="git-pull.html">git-pull(1)</a> and <a href="git-config.html">git-config(1)</a> for additional discussion on
1111 how the <code>branch.&lt;name&gt;.remote</code> and <code>branch.&lt;name&gt;.merge</code> options are used.</p></div>
1112 </dd>
1113 <dt class="hdlist1">
1114 --no-track
1115 </dt>
1116 <dd>
1118 Do not set up "upstream" configuration, even if the
1119 branch.autoSetupMerge configuration variable is set.
1120 </p>
1121 </dd>
1122 <dt class="hdlist1">
1123 --recurse-submodules
1124 </dt>
1125 <dd>
1127 THIS OPTION IS EXPERIMENTAL! Causes the current command to
1128 recurse into submodules if <code>submodule.propagateBranches</code> is
1129 enabled. See <code>submodule.propagateBranches</code> in
1130 <a href="git-config.html">git-config(1)</a>. Currently, only branch creation is
1131 supported.
1132 </p>
1133 <div class="paragraph"><p>When used in branch creation, a new branch &lt;branchname&gt; will be created
1134 in the superproject and all of the submodules in the superproject&#8217;s
1135 &lt;start-point&gt;. In submodules, the branch will point to the submodule
1136 commit in the superproject&#8217;s &lt;start-point&gt; but the branch&#8217;s tracking
1137 information will be set up based on the submodule&#8217;s branches and remotes
1138 e.g. <code>git branch --recurse-submodules topic origin/main</code> will create the
1139 submodule branch "topic" that points to the submodule commit in the
1140 superproject&#8217;s "origin/main", but tracks the submodule&#8217;s "origin/main".</p></div>
1141 </dd>
1142 <dt class="hdlist1">
1143 --set-upstream
1144 </dt>
1145 <dd>
1147 As this option had confusing syntax, it is no longer supported.
1148 Please use <code>--track</code> or <code>--set-upstream-to</code> instead.
1149 </p>
1150 </dd>
1151 <dt class="hdlist1">
1152 -u &lt;upstream&gt;
1153 </dt>
1154 <dt class="hdlist1">
1155 --set-upstream-to=&lt;upstream&gt;
1156 </dt>
1157 <dd>
1159 Set up &lt;branchname&gt;'s tracking information so &lt;upstream&gt; is
1160 considered &lt;branchname&gt;'s upstream branch. If no &lt;branchname&gt;
1161 is specified, then it defaults to the current branch.
1162 </p>
1163 </dd>
1164 <dt class="hdlist1">
1165 --unset-upstream
1166 </dt>
1167 <dd>
1169 Remove the upstream information for &lt;branchname&gt;. If no branch
1170 is specified it defaults to the current branch.
1171 </p>
1172 </dd>
1173 <dt class="hdlist1">
1174 --edit-description
1175 </dt>
1176 <dd>
1178 Open an editor and edit the text to explain what the branch is
1179 for, to be used by various other commands (e.g. <code>format-patch</code>,
1180 <code>request-pull</code>, and <code>merge</code> (if enabled)). Multi-line explanations
1181 may be used.
1182 </p>
1183 </dd>
1184 <dt class="hdlist1">
1185 --contains [&lt;commit&gt;]
1186 </dt>
1187 <dd>
1189 Only list branches which contain the specified commit (HEAD
1190 if not specified). Implies <code>--list</code>.
1191 </p>
1192 </dd>
1193 <dt class="hdlist1">
1194 --no-contains [&lt;commit&gt;]
1195 </dt>
1196 <dd>
1198 Only list branches which don&#8217;t contain the specified commit
1199 (HEAD if not specified). Implies <code>--list</code>.
1200 </p>
1201 </dd>
1202 <dt class="hdlist1">
1203 --merged [&lt;commit&gt;]
1204 </dt>
1205 <dd>
1207 Only list branches whose tips are reachable from the
1208 specified commit (HEAD if not specified). Implies <code>--list</code>.
1209 </p>
1210 </dd>
1211 <dt class="hdlist1">
1212 --no-merged [&lt;commit&gt;]
1213 </dt>
1214 <dd>
1216 Only list branches whose tips are not reachable from the
1217 specified commit (HEAD if not specified). Implies <code>--list</code>.
1218 </p>
1219 </dd>
1220 <dt class="hdlist1">
1221 &lt;branchname&gt;
1222 </dt>
1223 <dd>
1225 The name of the branch to create or delete.
1226 The new branch name must pass all checks defined by
1227 <a href="git-check-ref-format.html">git-check-ref-format(1)</a>. Some of these checks
1228 may restrict the characters allowed in a branch name.
1229 </p>
1230 </dd>
1231 <dt class="hdlist1">
1232 &lt;start-point&gt;
1233 </dt>
1234 <dd>
1236 The new branch head will point to this commit. It may be
1237 given as a branch name, a commit-id, or a tag. If this
1238 option is omitted, the current HEAD will be used instead.
1239 </p>
1240 </dd>
1241 <dt class="hdlist1">
1242 &lt;oldbranch&gt;
1243 </dt>
1244 <dd>
1246 The name of an existing branch to rename.
1247 </p>
1248 </dd>
1249 <dt class="hdlist1">
1250 &lt;newbranch&gt;
1251 </dt>
1252 <dd>
1254 The new name for an existing branch. The same restrictions as for
1255 &lt;branchname&gt; apply.
1256 </p>
1257 </dd>
1258 <dt class="hdlist1">
1259 --sort=&lt;key&gt;
1260 </dt>
1261 <dd>
1263 Sort based on the key given. Prefix <code>-</code> to sort in descending
1264 order of the value. You may use the --sort=&lt;key&gt; option
1265 multiple times, in which case the last key becomes the primary
1266 key. The keys supported are the same as those in <code>git
1267 for-each-ref</code>. Sort order defaults to the value configured for the
1268 <code>branch.sort</code> variable if it exists, or to sorting based on the
1269 full refname (including <code>refs/...</code> prefix). This lists
1270 detached HEAD (if present) first, then local branches and
1271 finally remote-tracking branches. See <a href="git-config.html">git-config(1)</a>.
1272 </p>
1273 </dd>
1274 <dt class="hdlist1">
1275 --points-at &lt;object&gt;
1276 </dt>
1277 <dd>
1279 Only list branches of the given object.
1280 </p>
1281 </dd>
1282 <dt class="hdlist1">
1283 --format &lt;format&gt;
1284 </dt>
1285 <dd>
1287 A string that interpolates <code>%(fieldname)</code> from a branch ref being shown
1288 and the object it points at. The format is the same as
1289 that of <a href="git-for-each-ref.html">git-for-each-ref(1)</a>.
1290 </p>
1291 </dd>
1292 </dl></div>
1293 </div>
1294 </div>
1295 <div class="sect1">
1296 <h2 id="_configuration">CONFIGURATION</h2>
1297 <div class="sectionbody">
1298 <div class="paragraph"><p><code>pager.branch</code> is only respected when listing branches, i.e., when
1299 <code>--list</code> is used or implied. The default is to use a pager.
1300 See <a href="git-config.html">git-config(1)</a>.</p></div>
1301 <div class="paragraph"><p>Everything above this line in this section isn&#8217;t included from the
1302 <a href="git-config.html">git-config(1)</a> documentation. The content that follows is the
1303 same as what&#8217;s found there:</p></div>
1304 <div class="dlist"><dl>
1305 <dt class="hdlist1">
1306 branch.autoSetupMerge
1307 </dt>
1308 <dd>
1310 Tells <em>git branch</em>, <em>git switch</em> and <em>git checkout</em> to set up new branches
1311 so that <a href="git-pull.html">git-pull(1)</a> will appropriately merge from the
1312 starting point branch. Note that even if this option is not set,
1313 this behavior can be chosen per-branch using the <code>--track</code>
1314 and <code>--no-track</code> options. The valid settings are: <code>false</code>&#8201;&#8212;&#8201;no
1315 automatic setup is done; <code>true</code>&#8201;&#8212;&#8201;automatic setup is done when the
1316 starting point is a remote-tracking branch; <code>always</code>&#8201;&#8212;&#8201; automatic setup is done when the starting point is either a
1317 local branch or remote-tracking branch; <code>inherit</code>&#8201;&#8212;&#8201;if the starting point
1318 has a tracking configuration, it is copied to the new
1319 branch; <code>simple</code>&#8201;&#8212;&#8201;automatic setup is done only when the starting point
1320 is a remote-tracking branch and the new branch has the same name as the
1321 remote branch. This option defaults to true.
1322 </p>
1323 </dd>
1324 <dt class="hdlist1">
1325 branch.autoSetupRebase
1326 </dt>
1327 <dd>
1329 When a new branch is created with <em>git branch</em>, <em>git switch</em> or <em>git checkout</em>
1330 that tracks another branch, this variable tells Git to set
1331 up pull to rebase instead of merge (see "branch.&lt;name&gt;.rebase").
1332 When <code>never</code>, rebase is never automatically set to true.
1333 When <code>local</code>, rebase is set to true for tracked branches of
1334 other local branches.
1335 When <code>remote</code>, rebase is set to true for tracked branches of
1336 remote-tracking branches.
1337 When <code>always</code>, rebase will be set to true for all tracking
1338 branches.
1339 See "branch.autoSetupMerge" for details on how to set up a
1340 branch to track another branch.
1341 This option defaults to never.
1342 </p>
1343 </dd>
1344 <dt class="hdlist1">
1345 branch.sort
1346 </dt>
1347 <dd>
1349 This variable controls the sort ordering of branches when displayed by
1350 <a href="git-branch.html">git-branch(1)</a>. Without the "--sort=&lt;value&gt;" option provided, the
1351 value of this variable will be used as the default.
1352 See <a href="git-for-each-ref.html">git-for-each-ref(1)</a> field names for valid values.
1353 </p>
1354 </dd>
1355 <dt class="hdlist1">
1356 branch.&lt;name&gt;.remote
1357 </dt>
1358 <dd>
1360 When on branch &lt;name&gt;, it tells <em>git fetch</em> and <em>git push</em>
1361 which remote to fetch from or push to. The remote to push to
1362 may be overridden with <code>remote.pushDefault</code> (for all branches).
1363 The remote to push to, for the current branch, may be further
1364 overridden by <code>branch.&lt;name&gt;.pushRemote</code>. If no remote is
1365 configured, or if you are not on any branch and there is more than
1366 one remote defined in the repository, it defaults to <code>origin</code> for
1367 fetching and <code>remote.pushDefault</code> for pushing.
1368 Additionally, <code>.</code> (a period) is the current local repository
1369 (a dot-repository), see <code>branch.&lt;name&gt;.merge</code>'s final note below.
1370 </p>
1371 </dd>
1372 <dt class="hdlist1">
1373 branch.&lt;name&gt;.pushRemote
1374 </dt>
1375 <dd>
1377 When on branch &lt;name&gt;, it overrides <code>branch.&lt;name&gt;.remote</code> for
1378 pushing. It also overrides <code>remote.pushDefault</code> for pushing
1379 from branch &lt;name&gt;. When you pull from one place (e.g. your
1380 upstream) and push to another place (e.g. your own publishing
1381 repository), you would want to set <code>remote.pushDefault</code> to
1382 specify the remote to push to for all branches, and use this
1383 option to override it for a specific branch.
1384 </p>
1385 </dd>
1386 <dt class="hdlist1">
1387 branch.&lt;name&gt;.merge
1388 </dt>
1389 <dd>
1391 Defines, together with branch.&lt;name&gt;.remote, the upstream branch
1392 for the given branch. It tells <em>git fetch</em>/<em>git pull</em>/<em>git rebase</em> which
1393 branch to merge and can also affect <em>git push</em> (see push.default).
1394 When in branch &lt;name&gt;, it tells <em>git fetch</em> the default
1395 refspec to be marked for merging in FETCH_HEAD. The value is
1396 handled like the remote part of a refspec, and must match a
1397 ref which is fetched from the remote given by
1398 "branch.&lt;name&gt;.remote".
1399 The merge information is used by <em>git pull</em> (which first calls
1400 <em>git fetch</em>) to lookup the default branch for merging. Without
1401 this option, <em>git pull</em> defaults to merge the first refspec fetched.
1402 Specify multiple values to get an octopus merge.
1403 If you wish to setup <em>git pull</em> so that it merges into &lt;name&gt; from
1404 another branch in the local repository, you can point
1405 branch.&lt;name&gt;.merge to the desired branch, and use the relative path
1406 setting <code>.</code> (a period) for branch.&lt;name&gt;.remote.
1407 </p>
1408 </dd>
1409 <dt class="hdlist1">
1410 branch.&lt;name&gt;.mergeOptions
1411 </dt>
1412 <dd>
1414 Sets default options for merging into branch &lt;name&gt;. The syntax and
1415 supported options are the same as those of <a href="git-merge.html">git-merge(1)</a>, but
1416 option values containing whitespace characters are currently not
1417 supported.
1418 </p>
1419 </dd>
1420 <dt class="hdlist1">
1421 branch.&lt;name&gt;.rebase
1422 </dt>
1423 <dd>
1425 When true, rebase the branch &lt;name&gt; on top of the fetched branch,
1426 instead of merging the default branch from the default remote when
1427 "git pull" is run. See "pull.rebase" for doing this in a non
1428 branch-specific manner.
1429 </p>
1430 <div class="paragraph"><p>When <code>merges</code> (or just <em>m</em>), pass the <code>--rebase-merges</code> option to <em>git rebase</em>
1431 so that the local merge commits are included in the rebase (see
1432 <a href="git-rebase.html">git-rebase(1)</a> for details).</p></div>
1433 <div class="paragraph"><p>When the value is <code>interactive</code> (or just <em>i</em>), the rebase is run in interactive
1434 mode.</p></div>
1435 <div class="paragraph"><p><strong>NOTE</strong>: this is a possibly dangerous operation; do <strong>not</strong> use
1436 it unless you understand the implications (see <a href="git-rebase.html">git-rebase(1)</a>
1437 for details).</p></div>
1438 </dd>
1439 <dt class="hdlist1">
1440 branch.&lt;name&gt;.description
1441 </dt>
1442 <dd>
1444 Branch description, can be edited with
1445 <code>git branch --edit-description</code>. Branch description is
1446 automatically added to the format-patch cover letter or
1447 request-pull summary.
1448 </p>
1449 </dd>
1450 </dl></div>
1451 </div>
1452 </div>
1453 <div class="sect1">
1454 <h2 id="_examples">EXAMPLES</h2>
1455 <div class="sectionbody">
1456 <div class="dlist"><dl>
1457 <dt class="hdlist1">
1458 Start development from a known tag
1459 </dt>
1460 <dd>
1461 <div class="listingblock">
1462 <div class="content">
1463 <pre><code>$ git clone git://git.kernel.org/pub/scm/.../linux-2.6 my2.6
1464 $ cd my2.6
1465 $ git branch my2.6.14 v2.6.14 <b>&lt;1&gt;</b>
1466 $ git switch my2.6.14</code></pre>
1467 </div></div>
1468 <div class="colist arabic"><ol>
1469 <li>
1471 This step and the next one could be combined into a single step with
1472 "checkout -b my2.6.14 v2.6.14".
1473 </p>
1474 </li>
1475 </ol></div>
1476 </dd>
1477 <dt class="hdlist1">
1478 Delete an unneeded branch
1479 </dt>
1480 <dd>
1481 <div class="listingblock">
1482 <div class="content">
1483 <pre><code>$ git clone git://git.kernel.org/.../git.git my.git
1484 $ cd my.git
1485 $ git branch -d -r origin/todo origin/html origin/man <b>&lt;1&gt;</b>
1486 $ git branch -D test <b>&lt;2&gt;</b></code></pre>
1487 </div></div>
1488 <div class="colist arabic"><ol>
1489 <li>
1491 Delete the remote-tracking branches "todo", "html" and "man". The next
1492 <em>fetch</em> or <em>pull</em> will create them again unless you configure them not to.
1493 See <a href="git-fetch.html">git-fetch(1)</a>.
1494 </p>
1495 </li>
1496 <li>
1498 Delete the "test" branch even if the "master" branch (or whichever branch
1499 is currently checked out) does not have all commits from the test branch.
1500 </p>
1501 </li>
1502 </ol></div>
1503 </dd>
1504 <dt class="hdlist1">
1505 Listing branches from a specific remote
1506 </dt>
1507 <dd>
1508 <div class="listingblock">
1509 <div class="content">
1510 <pre><code>$ git branch -r -l '&lt;remote&gt;/&lt;pattern&gt;' <b>&lt;1&gt;</b>
1511 $ git for-each-ref 'refs/remotes/&lt;remote&gt;/&lt;pattern&gt;' <b>&lt;2&gt;</b></code></pre>
1512 </div></div>
1513 <div class="colist arabic"><ol>
1514 <li>
1516 Using <code>-a</code> would conflate &lt;remote&gt; with any local branches you happen to
1517 have been prefixed with the same &lt;remote&gt; pattern.
1518 </p>
1519 </li>
1520 <li>
1522 <code>for-each-ref</code> can take a wide range of options. See <a href="git-for-each-ref.html">git-for-each-ref(1)</a>
1523 </p>
1524 </li>
1525 </ol></div>
1526 </dd>
1527 </dl></div>
1528 <div class="paragraph"><p>Patterns will normally need quoting.</p></div>
1529 </div>
1530 </div>
1531 <div class="sect1">
1532 <h2 id="_notes">NOTES</h2>
1533 <div class="sectionbody">
1534 <div class="paragraph"><p>If you are creating a branch that you want to switch to immediately,
1535 it is easier to use the "git switch" command with its <code>-c</code> option to
1536 do the same thing with a single command.</p></div>
1537 <div class="paragraph"><p>The options <code>--contains</code>, <code>--no-contains</code>, <code>--merged</code> and <code>--no-merged</code>
1538 serve four related but different purposes:</p></div>
1539 <div class="ulist"><ul>
1540 <li>
1542 <code>--contains &lt;commit&gt;</code> is used to find all branches which will need
1543 special attention if &lt;commit&gt; were to be rebased or amended, since those
1544 branches contain the specified &lt;commit&gt;.
1545 </p>
1546 </li>
1547 <li>
1549 <code>--no-contains &lt;commit&gt;</code> is the inverse of that, i.e. branches that don&#8217;t
1550 contain the specified &lt;commit&gt;.
1551 </p>
1552 </li>
1553 <li>
1555 <code>--merged</code> is used to find all branches which can be safely deleted,
1556 since those branches are fully contained by HEAD.
1557 </p>
1558 </li>
1559 <li>
1561 <code>--no-merged</code> is used to find branches which are candidates for merging
1562 into HEAD, since those branches are not fully contained by HEAD.
1563 </p>
1564 </li>
1565 </ul></div>
1566 <div class="paragraph"><p>When combining multiple <code>--contains</code> and <code>--no-contains</code> filters, only
1567 references that contain at least one of the <code>--contains</code> commits and
1568 contain none of the <code>--no-contains</code> commits are shown.</p></div>
1569 <div class="paragraph"><p>When combining multiple <code>--merged</code> and <code>--no-merged</code> filters, only
1570 references that are reachable from at least one of the <code>--merged</code>
1571 commits and from none of the <code>--no-merged</code> commits are shown.</p></div>
1572 </div>
1573 </div>
1574 <div class="sect1">
1575 <h2 id="_see_also">SEE ALSO</h2>
1576 <div class="sectionbody">
1577 <div class="paragraph"><p><a href="git-check-ref-format.html">git-check-ref-format(1)</a>,
1578 <a href="git-fetch.html">git-fetch(1)</a>,
1579 <a href="git-remote.html">git-remote(1)</a>,
1580 <a href="user-manual.html#what-is-a-branch">&#8220;Understanding history: What is
1581 a branch?&#8221;</a> in the Git User&#8217;s Manual.</p></div>
1582 </div>
1583 </div>
1584 <div class="sect1">
1585 <h2 id="_git">GIT</h2>
1586 <div class="sectionbody">
1587 <div class="paragraph"><p>Part of the <a href="git.html">git(1)</a> suite</p></div>
1588 </div>
1589 </div>
1590 </div>
1591 <div id="footnotes"><hr /></div>
1592 <div id="footer">
1593 <div id="footer-text">
1594 Last updated
1595 2023-10-30 08:42:00 JST
1596 </div>
1597 </div>
1598 </body>
1599 </html>