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">
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 */
14 font-family: Georgia,serif;
18 h1, h2, h3, h4, h5, h6,
19 div.title, caption.title,
20 thead, p.table.header,
22 #author, #revnumber, #revdate, #revremark,
24 font-family: Arial,Helvetica,sans-serif;
28 margin:
1em
5%
1em
5%;
33 text-decoration: underline;
49 h1, h2, h3, h4, h5, h6 {
57 border-bottom:
2px solid silver;
77 border:
1px solid silver;
88 ul
> li { color: #aaa; }
89 ul
> li
> * { color: black; }
91 .monospaced, code, pre {
92 font-family:
"Courier New", Courier, monospace;
99 white-space: pre-wrap;
109 #revnumber, #revdate, #revremark {
114 border-top:
2px solid silver;
120 padding-bottom:
0.5em;
124 padding-bottom:
0.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 {
135 margin-bottom:
1.5em;
137 div.admonitionblock {
139 margin-bottom:
2.0em;
144 div.content { /* Block element content. */
148 /* Block element titles. */
149 div.title, caption.title {
154 margin-bottom:
0.5em;
160 td div.title:first-child {
163 div.content div.title:first-child {
166 div.content + div.title {
170 div.sidebarblock
> div.content {
172 border:
1px solid #dddddd;
173 border-left:
4px solid #f0f0f0;
177 div.listingblock
> div.content {
178 border:
1px solid #dddddd;
179 border-left:
5px solid #f0f0f0;
184 div.quoteblock, div.verseblock {
188 border-left:
5px solid #f0f0f0;
192 div.quoteblock
> div.attribution {
197 div.verseblock
> pre.content {
198 font-family: inherit;
201 div.verseblock
> div.attribution {
205 /* DEPRECATED: Pre version
8.2.7 verse style literal block. */
206 div.verseblock + div.attribution {
210 div.admonitionblock .icon {
214 text-decoration: underline;
216 padding-right:
0.5em;
218 div.admonitionblock td.content {
220 border-left:
3px solid #dddddd;
223 div.exampleblock
> div.content {
224 border-left:
3px solid #dddddd;
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; }
234 margin-bottom:
0.8em;
247 list-style-position: outside;
250 list-style-type: decimal;
253 list-style-type: lower-alpha;
256 list-style-type: upper-alpha;
259 list-style-type: lower-roman;
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 {
269 margin-bottom:
0.1em;
281 margin-bottom:
0.8em;
284 padding-bottom:
15px;
286 dt.hdlist1.strong, td.hdlist1.strong {
292 padding-right:
0.8em;
298 div.hdlist.compact tr {
307 .footnote, .footnoteref {
311 span.footnote, span.footnoteref {
312 vertical-align: super;
316 margin:
20px
0 20px
0;
320 #footnotes div.footnote {
326 border-top:
1px solid silver;
335 padding-right:
0.5em;
336 padding-bottom:
0.3em;
344 #footer-badges { display: none; }
348 margin-bottom:
2.5em;
356 margin-bottom:
0.1em;
359 div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
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; }
427 margin-bottom:
1.5em;
429 div.tableblock
> table {
430 border:
3px solid #
527bbd;
432 thead, p.table.header {
439 /* Because the table frame attribute is overridden by CSS in most browsers. */
440 div.tableblock
> table[
frame=
"void"] {
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;
460 margin-bottom:
1.5em;
462 thead, p.tableblock.header {
473 border-color: #
527bbd;
474 border-collapse: collapse;
476 th.tableblock, td.tableblock {
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 {
498 th.tableblock.halign-center, td.tableblock.halign-center {
501 th.tableblock.halign-right, td.tableblock.halign-right {
505 th.tableblock.valign-top, td.tableblock.valign-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;
523 padding-bottom:
0.5em;
524 border-top:
2px solid silver;
525 border-bottom:
2px solid silver;
530 body.manpage div.sectionbody {
535 body.manpage div#toc { display: none; }
540 <script type=
"text/javascript">
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
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 */
562 toc: function (toclevels) {
564 function getText(el) {
566 for (var i = el.firstChild; i != null; i = i.nextSibling) {
567 if (i.nodeType ==
3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
569 else if (i.firstChild != null)
575 function TocEntry(el, text, toclevel) {
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
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);
602 var toc = document.getElementById(
"toc");
607 // Delete existing TOC entries in case we're reloading the TOC.
608 var tocEntriesToRemove = [];
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");
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.
651 var noteholder = document.getElementById(
"footnotes");
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");
670 for (i=
0; i
<spans.length; i++) {
671 if (spans[i].className ==
"footnote") {
673 var note = spans[i].getAttribute(
"data-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];
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;
692 noteholder.parentNode.removeChild(noteholder);
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.
701 "[<a href='#_footnote_" + n +
702 "' title='View footnote' class='footnote'>" + n +
"</a>]";
708 install: function(toclevels) {
711 function reinstall() {
712 asciidoc.footnotes();
714 asciidoc.toc(toclevels);
718 function reinstallAndRemoveTimer() {
719 clearInterval(timerId);
723 timerId = setInterval(reinstall,
500);
724 if (document.addEventListener)
725 document.addEventListener(
"DOMContentLoaded", reinstallAndRemoveTimer, false);
727 window.onload = reinstallAndRemoveTimer;
735 <body class=
"manpage">
738 git-branch(
1) Manual Page
741 <div class=
"sectionbody">
743 List, create, or delete branches
749 <h2 id=
"_synopsis">SYNOPSIS
</h2>
750 <div class=
"sectionbody">
751 <div class=
"verseblock">
752 <pre class=
"content"><em>git branch
</em> [--color[=
<when
>] | --no-color] [--show-current]
753 [-v [--abbrev=
<n
> | --no-abbrev]]
754 [--column[=
<options
>] | --no-column] [--sort=
<key
>]
755 [--merged [
<commit
>]] [--no-merged [
<commit
>]]
756 [--contains [
<commit
>]] [--no-contains [
<commit
>]]
757 [--points-at
<object
>] [--format=
<format
>]
758 [(-r | --remotes) | (-a | --all)]
759 [--list] [
<pattern
>…]
760 <em>git branch
</em> [--track[=(direct|inherit)] | --no-track] [-f]
761 [--recurse-submodules]
<branchname
> [
<start-point
>]
762 <em>git branch
</em> (--set-upstream-to=
<upstream
> | -u
<upstream
>) [
<branchname
>]
763 <em>git branch
</em> --unset-upstream [
<branchname
>]
764 <em>git branch
</em> (-m | -M) [
<oldbranch
>]
<newbranch
>
765 <em>git branch
</em> (-c | -C) [
<oldbranch
>]
<newbranch
>
766 <em>git branch
</em> (-d | -D) [-r]
<branchname
>…
767 <em>git branch
</em> --edit-description [
<branchname
>]
</pre>
768 <div class=
"attribution">
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><pattern
></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><pattern
></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
<commit
>
794 argument is missing it defaults to
<code>HEAD
</code> (i.e. the tip of the current
796 <div class=
"paragraph"><p>The command
’s second form creates a new branch head named
<branchname
>
797 which points to the current
<code>HEAD
</code>, or
<start-point
> if given. As a
798 special case, for
<start-point
>, 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 <newbranch>" 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.
<name
>.remote
</code> and
<code>branch.
<name
>.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,
<oldbranch
> will be renamed to
<newbranch
>.
813 If
<oldbranch
> had a corresponding reflog, it is renamed to match
814 <newbranch
>, and a reflog entry is created to remember the branch
815 renaming. If
<newbranch
> exists, -M must be used to force the rename
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><branchname
></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>
831 <h2 id=
"_options">OPTIONS
</h2>
832 <div class=
"sectionbody">
833 <div class=
"dlist"><dl>
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>.
852 Shortcut for
<code>--delete --force
</code>.
860 Create the branch
’s reflog. This activates recording of
861 all changes made to the branch ref, enabling use of date
862 based sha1 expressions such as
"<branchname>@{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>.
878 Reset
<branchname
> to
<start-point
>, even if
<branchname
> 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>).
886 <div class=
"paragraph"><p>Note that
<em>git branch -f
<branchname
> [
<start-point
>]
</em>, even with
<em>-f
</em>,
887 refuses to change an existing branch
<code><branchname
></code> that is checked out
888 in another worktree linked to the same repository.
</p></div>
898 Move/rename a branch, together with its config and reflog.
906 Shortcut for
<code>--move --force
</code>.
917 Copy a branch, together with its config and reflog.
925 Shortcut for
<code>--copy --force
</code>.
929 --color[=
<when
>]
933 Color branches to highlight current, local, and
934 remote-tracking branches.
935 The value must be always (the default), never, or auto.
943 Turn off branch colors, even when the configuration file gives the
944 default to color output.
945 Same as
<code>--color=never
</code>.
956 Sorting and filtering branches are case insensitive.
964 Do not print a newline after formatted refs where the format expands
969 --column[=
<options
>]
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.
980 <div class=
"paragraph"><p>This option is only applicable in non-verbose mode.
</p></div>
990 List or delete (if used with -d) the remote-tracking branches.
991 Combine with
<code>--list
</code> to match the optional pattern(s).
1002 List both remote-tracking branches and local branches.
1003 Combine with
<code>--list
</code> to match optional pattern(s).
1006 <dt class=
"hdlist1">
1009 <dt class=
"hdlist1">
1014 List branches. With optional
<code><pattern
>...
</code>, e.g.
<code>git
1015 branch --list 'maint-*'
</code>, list only the branches that match
1019 <dt class=
"hdlist1">
1024 Print the name of the current branch. In detached HEAD state,
1028 <dt class=
"hdlist1">
1031 <dt class=
"hdlist1">
1034 <dt class=
"hdlist1">
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
<remote
></code>). Note that the
1044 current worktree
’s HEAD will not have its path printed (it will always
1045 be your current directory).
1048 <dt class=
"hdlist1">
1051 <dt class=
"hdlist1">
1056 Be more quiet when creating or deleting a branch, suppressing
1060 <dt class=
"hdlist1">
1065 In the verbose listing that show the commit object name,
1066 show the shortest prefix that is at least
<em><n
></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>
1072 <dt class=
"hdlist1">
1077 Display the full sha1s in the output listing rather than abbreviating them.
1080 <dt class=
"hdlist1">
1083 <dt class=
"hdlist1">
1084 --track[=(direct|inherit)]
1088 When creating a new branch, set up
<code>branch.
<name
>.remote
</code> and
1089 <code>branch.
<name
>.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.
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.
<name
>.remote
</code> and
<code>branch.
<name
>.merge
</code> options are used.
</p></div>
1113 <dt class=
"hdlist1">
1118 Do not set up
"upstream" configuration, even if the
1119 branch.autoSetupMerge configuration variable is set.
1122 <dt class=
"hdlist1">
1123 --recurse-submodules
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
1133 <div class=
"paragraph"><p>When used in branch creation, a new branch
<branchname
> will be created
1134 in the superproject and all of the submodules in the superproject
’s
1135 <start-point
>. In submodules, the branch will point to the submodule
1136 commit in the superproject
’s
<start-point
> but the branch
’s tracking
1137 information will be set up based on the submodule
’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
’s
"origin/main", but tracks the submodule
’s
"origin/main".
</p></div>
1142 <dt class=
"hdlist1">
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.
1151 <dt class=
"hdlist1">
1154 <dt class=
"hdlist1">
1155 --set-upstream-to=
<upstream
>
1159 Set up
<branchname
>'s tracking information so
<upstream
> is
1160 considered
<branchname
>'s upstream branch. If no
<branchname
>
1161 is specified, then it defaults to the current branch.
1164 <dt class=
"hdlist1">
1169 Remove the upstream information for
<branchname
>. If no branch
1170 is specified it defaults to the current branch.
1173 <dt class=
"hdlist1">
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
1184 <dt class=
"hdlist1">
1185 --contains [
<commit
>]
1189 Only list branches which contain the specified commit (HEAD
1190 if not specified). Implies
<code>--list
</code>.
1193 <dt class=
"hdlist1">
1194 --no-contains [
<commit
>]
1198 Only list branches which don
’t contain the specified commit
1199 (HEAD if not specified). Implies
<code>--list
</code>.
1202 <dt class=
"hdlist1">
1203 --merged [
<commit
>]
1207 Only list branches whose tips are reachable from the
1208 specified commit (HEAD if not specified). Implies
<code>--list
</code>.
1211 <dt class=
"hdlist1">
1212 --no-merged [
<commit
>]
1216 Only list branches whose tips are not reachable from the
1217 specified commit (HEAD if not specified). Implies
<code>--list
</code>.
1220 <dt class=
"hdlist1">
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.
1231 <dt class=
"hdlist1">
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.
1241 <dt class=
"hdlist1">
1246 The name of an existing branch. If this option is omitted,
1247 the name of the current branch will be used instead.
1250 <dt class=
"hdlist1">
1255 The new name for an existing branch. The same restrictions as for
1256 <branchname
> apply.
1259 <dt class=
"hdlist1">
1264 Sort based on the key given. Prefix
<code>-
</code> to sort in descending
1265 order of the value. You may use the --sort=
<key
> option
1266 multiple times, in which case the last key becomes the primary
1267 key. The keys supported are the same as those in
<code>git
1268 for-each-ref
</code>. Sort order defaults to the value configured for the
1269 <code>branch.sort
</code> variable if it exists, or to sorting based on the
1270 full refname (including
<code>refs/...
</code> prefix). This lists
1271 detached HEAD (if present) first, then local branches and
1272 finally remote-tracking branches. See
<a href=
"git-config.html">git-config(
1)
</a>.
1275 <dt class=
"hdlist1">
1276 --points-at
<object
>
1280 Only list branches of the given object.
1283 <dt class=
"hdlist1">
1284 --format
<format
>
1288 A string that interpolates
<code>%(fieldname)
</code> from a branch ref being shown
1289 and the object it points at. The format is the same as
1290 that of
<a href=
"git-for-each-ref.html">git-for-each-ref(
1)
</a>.
1297 <h2 id=
"_configuration">CONFIGURATION
</h2>
1298 <div class=
"sectionbody">
1299 <div class=
"paragraph"><p><code>pager.branch
</code> is only respected when listing branches, i.e., when
1300 <code>--list
</code> is used or implied. The default is to use a pager.
1301 See
<a href=
"git-config.html">git-config(
1)
</a>.
</p></div>
1302 <div class=
"paragraph"><p>Everything above this line in this section isn
’t included from the
1303 <a href=
"git-config.html">git-config(
1)
</a> documentation. The content that follows is the
1304 same as what
’s found there:
</p></div>
1305 <div class=
"dlist"><dl>
1306 <dt class=
"hdlist1">
1307 branch.autoSetupMerge
1311 Tells
<em>git branch
</em>,
<em>git switch
</em> and
<em>git checkout
</em> to set up new branches
1312 so that
<a href=
"git-pull.html">git-pull(
1)
</a> will appropriately merge from the
1313 starting point branch. Note that even if this option is not set,
1314 this behavior can be chosen per-branch using the
<code>--track
</code>
1315 and
<code>--no-track
</code> options. The valid settings are:
<code>false
</code> — no
1316 automatic setup is done;
<code>true
</code> — automatic setup is done when the
1317 starting point is a remote-tracking branch;
<code>always
</code> —  automatic setup is done when the starting point is either a
1318 local branch or remote-tracking branch;
<code>inherit
</code> — if the starting point
1319 has a tracking configuration, it is copied to the new
1320 branch;
<code>simple
</code> — automatic setup is done only when the starting point
1321 is a remote-tracking branch and the new branch has the same name as the
1322 remote branch. This option defaults to true.
1325 <dt class=
"hdlist1">
1326 branch.autoSetupRebase
1330 When a new branch is created with
<em>git branch
</em>,
<em>git switch
</em> or
<em>git checkout
</em>
1331 that tracks another branch, this variable tells Git to set
1332 up pull to rebase instead of merge (see
"branch.<name>.rebase").
1333 When
<code>never
</code>, rebase is never automatically set to true.
1334 When
<code>local
</code>, rebase is set to true for tracked branches of
1335 other local branches.
1336 When
<code>remote
</code>, rebase is set to true for tracked branches of
1337 remote-tracking branches.
1338 When
<code>always
</code>, rebase will be set to true for all tracking
1340 See
"branch.autoSetupMerge" for details on how to set up a
1341 branch to track another branch.
1342 This option defaults to never.
1345 <dt class=
"hdlist1">
1350 This variable controls the sort ordering of branches when displayed by
1351 <a href=
"git-branch.html">git-branch(
1)
</a>. Without the
"--sort=<value>" option provided, the
1352 value of this variable will be used as the default.
1353 See
<a href=
"git-for-each-ref.html">git-for-each-ref(
1)
</a> field names for valid values.
1356 <dt class=
"hdlist1">
1357 branch.
<name
>.remote
1361 When on branch
<name
>, it tells
<em>git fetch
</em> and
<em>git push
</em>
1362 which remote to fetch from or push to. The remote to push to
1363 may be overridden with
<code>remote.pushDefault
</code> (for all branches).
1364 The remote to push to, for the current branch, may be further
1365 overridden by
<code>branch.
<name
>.pushRemote
</code>. If no remote is
1366 configured, or if you are not on any branch and there is more than
1367 one remote defined in the repository, it defaults to
<code>origin
</code> for
1368 fetching and
<code>remote.pushDefault
</code> for pushing.
1369 Additionally,
<code>.
</code> (a period) is the current local repository
1370 (a dot-repository), see
<code>branch.
<name
>.merge
</code>'s final note below.
1373 <dt class=
"hdlist1">
1374 branch.
<name
>.pushRemote
1378 When on branch
<name
>, it overrides
<code>branch.
<name
>.remote
</code> for
1379 pushing. It also overrides
<code>remote.pushDefault
</code> for pushing
1380 from branch
<name
>. When you pull from one place (e.g. your
1381 upstream) and push to another place (e.g. your own publishing
1382 repository), you would want to set
<code>remote.pushDefault
</code> to
1383 specify the remote to push to for all branches, and use this
1384 option to override it for a specific branch.
1387 <dt class=
"hdlist1">
1388 branch.
<name
>.merge
1392 Defines, together with branch.
<name
>.remote, the upstream branch
1393 for the given branch. It tells
<em>git fetch
</em>/
<em>git pull
</em>/
<em>git rebase
</em> which
1394 branch to merge and can also affect
<em>git push
</em> (see push.default).
1395 When in branch
<name
>, it tells
<em>git fetch
</em> the default
1396 refspec to be marked for merging in FETCH_HEAD. The value is
1397 handled like the remote part of a refspec, and must match a
1398 ref which is fetched from the remote given by
1399 "branch.<name>.remote".
1400 The merge information is used by
<em>git pull
</em> (which first calls
1401 <em>git fetch
</em>) to lookup the default branch for merging. Without
1402 this option,
<em>git pull
</em> defaults to merge the first refspec fetched.
1403 Specify multiple values to get an octopus merge.
1404 If you wish to setup
<em>git pull
</em> so that it merges into
<name
> from
1405 another branch in the local repository, you can point
1406 branch.
<name
>.merge to the desired branch, and use the relative path
1407 setting
<code>.
</code> (a period) for branch.
<name
>.remote.
1410 <dt class=
"hdlist1">
1411 branch.
<name
>.mergeOptions
1415 Sets default options for merging into branch
<name
>. The syntax and
1416 supported options are the same as those of
<a href=
"git-merge.html">git-merge(
1)
</a>, but
1417 option values containing whitespace characters are currently not
1421 <dt class=
"hdlist1">
1422 branch.
<name
>.rebase
1426 When true, rebase the branch
<name
> on top of the fetched branch,
1427 instead of merging the default branch from the default remote when
1428 "git pull" is run. See
"pull.rebase" for doing this in a non
1429 branch-specific manner.
1431 <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>
1432 so that the local merge commits are included in the rebase (see
1433 <a href=
"git-rebase.html">git-rebase(
1)
</a> for details).
</p></div>
1434 <div class=
"paragraph"><p>When the value is
<code>interactive
</code> (or just
<em>i
</em>), the rebase is run in interactive
1436 <div class=
"paragraph"><p><strong>NOTE
</strong>: this is a possibly dangerous operation; do
<strong>not
</strong> use
1437 it unless you understand the implications (see
<a href=
"git-rebase.html">git-rebase(
1)
</a>
1438 for details).
</p></div>
1440 <dt class=
"hdlist1">
1441 branch.
<name
>.description
1445 Branch description, can be edited with
1446 <code>git branch --edit-description
</code>. Branch description is
1447 automatically added to the format-patch cover letter or
1448 request-pull summary.
1455 <h2 id=
"_examples">EXAMPLES
</h2>
1456 <div class=
"sectionbody">
1457 <div class=
"dlist"><dl>
1458 <dt class=
"hdlist1">
1459 Start development from a known tag
1462 <div class=
"listingblock">
1463 <div class=
"content">
1464 <pre><code>$ git clone git://git.kernel.org/pub/scm/.../linux-
2.6 my2.6
1466 $ git branch my2.6
.14 v2.6
.14 <b><1></b>
1467 $ git switch my2.6
.14</code></pre>
1469 <div class=
"colist arabic"><ol>
1472 This step and the next one could be combined into a single step with
1473 "checkout -b my2.6.14 v2.6.14".
1478 <dt class=
"hdlist1">
1479 Delete an unneeded branch
1482 <div class=
"listingblock">
1483 <div class=
"content">
1484 <pre><code>$ git clone git://git.kernel.org/.../git.git my.git
1486 $ git branch -d -r origin/todo origin/html origin/man
<b><1></b>
1487 $ git branch -D test
<b><2></b></code></pre>
1489 <div class=
"colist arabic"><ol>
1492 Delete the remote-tracking branches
"todo",
"html" and
"man". The next
1493 <em>fetch
</em> or
<em>pull
</em> will create them again unless you configure them not to.
1494 See
<a href=
"git-fetch.html">git-fetch(
1)
</a>.
1499 Delete the
"test" branch even if the
"master" branch (or whichever branch
1500 is currently checked out) does not have all commits from the test branch.
1505 <dt class=
"hdlist1">
1506 Listing branches from a specific remote
1509 <div class=
"listingblock">
1510 <div class=
"content">
1511 <pre><code>$ git branch -r -l '
<remote
>/
<pattern
>'
<b><1></b>
1512 $ git for-each-ref 'refs/remotes/
<remote
>/
<pattern
>'
<b><2></b></code></pre>
1514 <div class=
"colist arabic"><ol>
1517 Using
<code>-a
</code> would conflate
<remote
> with any local branches you happen to
1518 have been prefixed with the same
<remote
> pattern.
1523 <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>
1529 <div class=
"paragraph"><p>Patterns will normally need quoting.
</p></div>
1533 <h2 id=
"_notes">NOTES
</h2>
1534 <div class=
"sectionbody">
1535 <div class=
"paragraph"><p>If you are creating a branch that you want to switch to immediately,
1536 it is easier to use the
"git switch" command with its
<code>-c
</code> option to
1537 do the same thing with a single command.
</p></div>
1538 <div class=
"paragraph"><p>The options
<code>--contains
</code>,
<code>--no-contains
</code>,
<code>--merged
</code> and
<code>--no-merged
</code>
1539 serve four related but different purposes:
</p></div>
1540 <div class=
"ulist"><ul>
1543 <code>--contains
<commit
></code> is used to find all branches which will need
1544 special attention if
<commit
> were to be rebased or amended, since those
1545 branches contain the specified
<commit
>.
1550 <code>--no-contains
<commit
></code> is the inverse of that, i.e. branches that don
’t
1551 contain the specified
<commit
>.
1556 <code>--merged
</code> is used to find all branches which can be safely deleted,
1557 since those branches are fully contained by HEAD.
1562 <code>--no-merged
</code> is used to find branches which are candidates for merging
1563 into HEAD, since those branches are not fully contained by HEAD.
1567 <div class=
"paragraph"><p>When combining multiple
<code>--contains
</code> and
<code>--no-contains
</code> filters, only
1568 references that contain at least one of the
<code>--contains
</code> commits and
1569 contain none of the
<code>--no-contains
</code> commits are shown.
</p></div>
1570 <div class=
"paragraph"><p>When combining multiple
<code>--merged
</code> and
<code>--no-merged
</code> filters, only
1571 references that are reachable from at least one of the
<code>--merged
</code>
1572 commits and from none of the
<code>--no-merged
</code> commits are shown.
</p></div>
1576 <h2 id=
"_see_also">SEE ALSO
</h2>
1577 <div class=
"sectionbody">
1578 <div class=
"paragraph"><p><a href=
"git-check-ref-format.html">git-check-ref-format(
1)
</a>,
1579 <a href=
"git-fetch.html">git-fetch(
1)
</a>,
1580 <a href=
"git-remote.html">git-remote(
1)
</a>,
1581 <a href=
"user-manual.html#what-is-a-branch">“Understanding history: What is
1582 a branch?
”</a> in the Git User
’s Manual.
</p></div>
1586 <h2 id=
"_git">GIT
</h2>
1587 <div class=
"sectionbody">
1588 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
1592 <div id=
"footnotes"><hr /></div>
1594 <div id=
"footer-text">
1596 2024-
01-
19 16:
47:
36 PST