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
<startpoint
>, 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>).
895 Move/rename a branch, together with its config and reflog.
903 Shortcut for
<code>--move --force
</code>.
914 Copy a branch, together with its config and reflog.
922 Shortcut for
<code>--copy --force
</code>.
926 --color[=
<when
>]
930 Color branches to highlight current, local, and
931 remote-tracking branches.
932 The value must be always (the default), never, or auto.
940 Turn off branch colors, even when the configuration file gives the
941 default to color output.
942 Same as
<code>--color=never
</code>.
953 Sorting and filtering branches are case insensitive.
957 --column[=
<options
>]
964 Display branch listing in columns. See configuration variable
965 <code>column.branch
</code> for option syntax.
<code>--column
</code> and
<code>--no-column
</code>
966 without options are equivalent to
<em>always
</em> and
<em>never
</em> respectively.
968 <div class=
"paragraph"><p>This option is only applicable in non-verbose mode.
</p></div>
978 List or delete (if used with -d) the remote-tracking branches.
979 Combine with
<code>--list
</code> to match the optional pattern(s).
990 List both remote-tracking branches and local branches.
991 Combine with
<code>--list
</code> to match optional pattern(s).
1002 List branches. With optional
<code><pattern
>...
</code>, e.g.
<code>git
1003 branch --list 'maint-*'
</code>, list only the branches that match
1007 <dt class=
"hdlist1">
1012 Print the name of the current branch. In detached HEAD state,
1016 <dt class=
"hdlist1">
1019 <dt class=
"hdlist1">
1022 <dt class=
"hdlist1">
1028 show sha1 and commit subject line for each head, along with
1029 relationship to upstream branch (if any). If given twice, print
1030 the path of the linked worktree (if any) and the name of the upstream
1031 branch, as well (see also
<code>git remote show
<remote
></code>). Note that the
1032 current worktree
’s HEAD will not have its path printed (it will always
1033 be your current directory).
1036 <dt class=
"hdlist1">
1039 <dt class=
"hdlist1">
1044 Be more quiet when creating or deleting a branch, suppressing
1048 <dt class=
"hdlist1">
1053 In the verbose listing that show the commit object name,
1054 show the shortest prefix that is at least
<em><n
></em> hexdigits
1055 long that uniquely refers the object.
1056 The default value is
7 and can be overridden by the
<code>core.abbrev
</code>
1060 <dt class=
"hdlist1">
1065 Display the full sha1s in the output listing rather than abbreviating them.
1068 <dt class=
"hdlist1">
1071 <dt class=
"hdlist1">
1072 --track[=(direct|inherit)]
1076 When creating a new branch, set up
<code>branch.
<name
>.remote
</code> and
1077 <code>branch.
<name
>.merge
</code> configuration entries to set
"upstream" tracking
1078 configuration for the new branch. This
1079 configuration will tell git to show the relationship between the
1080 two branches in
<code>git status
</code> and
<code>git branch -v
</code>. Furthermore,
1081 it directs
<code>git pull
</code> without arguments to pull from the
1082 upstream when the new branch is checked out.
1084 <div class=
"paragraph"><p>The exact upstream branch is chosen depending on the optional argument:
1085 <code>-t
</code>,
<code>--track
</code>, or
<code>--track=direct
</code> means to use the start-point branch
1086 itself as the upstream;
<code>--track=inherit
</code> means to copy the upstream
1087 configuration of the start-point branch.
</p></div>
1088 <div class=
"paragraph"><p>The branch.autoSetupMerge configuration variable specifies how
<code>git switch
</code>,
1089 <code>git checkout
</code> and
<code>git branch
</code> should behave when neither
<code>--track
</code> nor
1090 <code>--no-track
</code> are specified:
</p></div>
1091 <div class=
"paragraph"><p>The default option,
<code>true
</code>, behaves as though
<code>--track=direct
</code>
1092 were given whenever the start-point is a remote-tracking branch.
1093 <code>false
</code> behaves as if
<code>--no-track
</code> were given.
<code>always
</code> behaves as though
1094 <code>--track=direct
</code> were given.
<code>inherit
</code> behaves as though
<code>--track=inherit
</code>
1095 were given.
<code>simple
</code> behaves as though
<code>--track=direct
</code> were given only when
1096 the start-point is a remote-tracking branch and the new branch has the same
1097 name as the remote branch.
</p></div>
1098 <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
1099 how the
<code>branch.
<name
>.remote
</code> and
<code>branch.
<name
>.merge
</code> options are used.
</p></div>
1101 <dt class=
"hdlist1">
1106 Do not set up
"upstream" configuration, even if the
1107 branch.autoSetupMerge configuration variable is set.
1110 <dt class=
"hdlist1">
1111 --recurse-submodules
1115 THIS OPTION IS EXPERIMENTAL! Causes the current command to
1116 recurse into submodules if
<code>submodule.propagateBranches
</code> is
1117 enabled. See
<code>submodule.propagateBranches
</code> in
1118 <a href=
"git-config.html">git-config(
1)
</a>. Currently, only branch creation is
1121 <div class=
"paragraph"><p>When used in branch creation, a new branch
<branchname
> will be created
1122 in the superproject and all of the submodules in the superproject
’s
1123 <start-point
>. In submodules, the branch will point to the submodule
1124 commit in the superproject
’s
<start-point
> but the branch
’s tracking
1125 information will be set up based on the submodule
’s branches and remotes
1126 e.g.
<code>git branch --recurse-submodules topic origin/main
</code> will create the
1127 submodule branch
"topic" that points to the submodule commit in the
1128 superproject
’s
"origin/main", but tracks the submodule
’s
"origin/main".
</p></div>
1130 <dt class=
"hdlist1">
1135 As this option had confusing syntax, it is no longer supported.
1136 Please use
<code>--track
</code> or
<code>--set-upstream-to
</code> instead.
1139 <dt class=
"hdlist1">
1142 <dt class=
"hdlist1">
1143 --set-upstream-to=
<upstream
>
1147 Set up
<branchname
>'s tracking information so
<upstream
> is
1148 considered
<branchname
>'s upstream branch. If no
<branchname
>
1149 is specified, then it defaults to the current branch.
1152 <dt class=
"hdlist1">
1157 Remove the upstream information for
<branchname
>. If no branch
1158 is specified it defaults to the current branch.
1161 <dt class=
"hdlist1">
1166 Open an editor and edit the text to explain what the branch is
1167 for, to be used by various other commands (e.g.
<code>format-patch
</code>,
1168 <code>request-pull
</code>, and
<code>merge
</code> (if enabled)). Multi-line explanations
1172 <dt class=
"hdlist1">
1173 --contains [
<commit
>]
1177 Only list branches which contain the specified commit (HEAD
1178 if not specified). Implies
<code>--list
</code>.
1181 <dt class=
"hdlist1">
1182 --no-contains [
<commit
>]
1186 Only list branches which don
’t contain the specified commit
1187 (HEAD if not specified). Implies
<code>--list
</code>.
1190 <dt class=
"hdlist1">
1191 --merged [
<commit
>]
1195 Only list branches whose tips are reachable from the
1196 specified commit (HEAD if not specified). Implies
<code>--list
</code>.
1199 <dt class=
"hdlist1">
1200 --no-merged [
<commit
>]
1204 Only list branches whose tips are not reachable from the
1205 specified commit (HEAD if not specified). Implies
<code>--list
</code>.
1208 <dt class=
"hdlist1">
1213 The name of the branch to create or delete.
1214 The new branch name must pass all checks defined by
1215 <a href=
"git-check-ref-format.html">git-check-ref-format(
1)
</a>. Some of these checks
1216 may restrict the characters allowed in a branch name.
1219 <dt class=
"hdlist1">
1224 The new branch head will point to this commit. It may be
1225 given as a branch name, a commit-id, or a tag. If this
1226 option is omitted, the current HEAD will be used instead.
1229 <dt class=
"hdlist1">
1234 The name of an existing branch to rename.
1237 <dt class=
"hdlist1">
1242 The new name for an existing branch. The same restrictions as for
1243 <branchname
> apply.
1246 <dt class=
"hdlist1">
1251 Sort based on the key given. Prefix
<code>-
</code> to sort in descending
1252 order of the value. You may use the --sort=
<key
> option
1253 multiple times, in which case the last key becomes the primary
1254 key. The keys supported are the same as those in
<code>git
1255 for-each-ref
</code>. Sort order defaults to the value configured for the
1256 <code>branch.sort
</code> variable if exists, or to sorting based on the
1257 full refname (including
<code>refs/...
</code> prefix). This lists
1258 detached HEAD (if present) first, then local branches and
1259 finally remote-tracking branches. See
<a href=
"git-config.html">git-config(
1)
</a>.
1262 <dt class=
"hdlist1">
1263 --points-at
<object
>
1267 Only list branches of the given object.
1270 <dt class=
"hdlist1">
1271 --format
<format
>
1275 A string that interpolates
<code>%(fieldname)
</code> from a branch ref being shown
1276 and the object it points at. The format is the same as
1277 that of
<a href=
"git-for-each-ref.html">git-for-each-ref(
1)
</a>.
1284 <h2 id=
"_configuration">CONFIGURATION
</h2>
1285 <div class=
"sectionbody">
1286 <div class=
"paragraph"><p><code>pager.branch
</code> is only respected when listing branches, i.e., when
1287 <code>--list
</code> is used or implied. The default is to use a pager.
1288 See
<a href=
"git-config.html">git-config(
1)
</a>.
</p></div>
1289 <div class=
"paragraph"><p>Everything above this line in this section isn
’t included from the
1290 <a href=
"git-config.html">git-config(
1)
</a> documentation. The content that follows is the
1291 same as what
’s found there:
</p></div>
1292 <div class=
"dlist"><dl>
1293 <dt class=
"hdlist1">
1294 branch.autoSetupMerge
1298 Tells
<em>git branch
</em>,
<em>git switch
</em> and
<em>git checkout
</em> to set up new branches
1299 so that
<a href=
"git-pull.html">git-pull(
1)
</a> will appropriately merge from the
1300 starting point branch. Note that even if this option is not set,
1301 this behavior can be chosen per-branch using the
<code>--track
</code>
1302 and
<code>--no-track
</code> options. The valid settings are:
<code>false
</code> — no
1303 automatic setup is done;
<code>true
</code> — automatic setup is done when the
1304 starting point is a remote-tracking branch;
<code>always
</code> —  automatic setup is done when the starting point is either a
1305 local branch or remote-tracking branch;
<code>inherit
</code> — if the starting point
1306 has a tracking configuration, it is copied to the new
1307 branch;
<code>simple
</code> — automatic setup is done only when the starting point
1308 is a remote-tracking branch and the new branch has the same name as the
1309 remote branch. This option defaults to true.
1312 <dt class=
"hdlist1">
1313 branch.autoSetupRebase
1317 When a new branch is created with
<em>git branch
</em>,
<em>git switch
</em> or
<em>git checkout
</em>
1318 that tracks another branch, this variable tells Git to set
1319 up pull to rebase instead of merge (see
"branch.<name>.rebase").
1320 When
<code>never
</code>, rebase is never automatically set to true.
1321 When
<code>local
</code>, rebase is set to true for tracked branches of
1322 other local branches.
1323 When
<code>remote
</code>, rebase is set to true for tracked branches of
1324 remote-tracking branches.
1325 When
<code>always
</code>, rebase will be set to true for all tracking
1327 See
"branch.autoSetupMerge" for details on how to set up a
1328 branch to track another branch.
1329 This option defaults to never.
1332 <dt class=
"hdlist1">
1337 This variable controls the sort ordering of branches when displayed by
1338 <a href=
"git-branch.html">git-branch(
1)
</a>. Without the
"--sort=<value>" option provided, the
1339 value of this variable will be used as the default.
1340 See
<a href=
"git-for-each-ref.html">git-for-each-ref(
1)
</a> field names for valid values.
1343 <dt class=
"hdlist1">
1344 branch.
<name
>.remote
1348 When on branch
<name
>, it tells
<em>git fetch
</em> and
<em>git push
</em>
1349 which remote to fetch from/push to. The remote to push to
1350 may be overridden with
<code>remote.pushDefault
</code> (for all branches).
1351 The remote to push to, for the current branch, may be further
1352 overridden by
<code>branch.
<name
>.pushRemote
</code>. If no remote is
1353 configured, or if you are not on any branch and there is more than
1354 one remote defined in the repository, it defaults to
<code>origin
</code> for
1355 fetching and
<code>remote.pushDefault
</code> for pushing.
1356 Additionally,
<code>.
</code> (a period) is the current local repository
1357 (a dot-repository), see
<code>branch.
<name
>.merge
</code>'s final note below.
1360 <dt class=
"hdlist1">
1361 branch.
<name
>.pushRemote
1365 When on branch
<name
>, it overrides
<code>branch.
<name
>.remote
</code> for
1366 pushing. It also overrides
<code>remote.pushDefault
</code> for pushing
1367 from branch
<name
>. When you pull from one place (e.g. your
1368 upstream) and push to another place (e.g. your own publishing
1369 repository), you would want to set
<code>remote.pushDefault
</code> to
1370 specify the remote to push to for all branches, and use this
1371 option to override it for a specific branch.
1374 <dt class=
"hdlist1">
1375 branch.
<name
>.merge
1379 Defines, together with branch.
<name
>.remote, the upstream branch
1380 for the given branch. It tells
<em>git fetch
</em>/
<em>git pull
</em>/
<em>git rebase
</em> which
1381 branch to merge and can also affect
<em>git push
</em> (see push.default).
1382 When in branch
<name
>, it tells
<em>git fetch
</em> the default
1383 refspec to be marked for merging in FETCH_HEAD. The value is
1384 handled like the remote part of a refspec, and must match a
1385 ref which is fetched from the remote given by
1386 "branch.<name>.remote".
1387 The merge information is used by
<em>git pull
</em> (which at first calls
1388 <em>git fetch
</em>) to lookup the default branch for merging. Without
1389 this option,
<em>git pull
</em> defaults to merge the first refspec fetched.
1390 Specify multiple values to get an octopus merge.
1391 If you wish to setup
<em>git pull
</em> so that it merges into
<name
> from
1392 another branch in the local repository, you can point
1393 branch.
<name
>.merge to the desired branch, and use the relative path
1394 setting
<code>.
</code> (a period) for branch.
<name
>.remote.
1397 <dt class=
"hdlist1">
1398 branch.
<name
>.mergeOptions
1402 Sets default options for merging into branch
<name
>. The syntax and
1403 supported options are the same as those of
<a href=
"git-merge.html">git-merge(
1)
</a>, but
1404 option values containing whitespace characters are currently not
1408 <dt class=
"hdlist1">
1409 branch.
<name
>.rebase
1413 When true, rebase the branch
<name
> on top of the fetched branch,
1414 instead of merging the default branch from the default remote when
1415 "git pull" is run. See
"pull.rebase" for doing this in a non
1416 branch-specific manner.
1418 <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>
1419 so that the local merge commits are included in the rebase (see
1420 <a href=
"git-rebase.html">git-rebase(
1)
</a> for details).
</p></div>
1421 <div class=
"paragraph"><p>When the value is
<code>interactive
</code> (or just
<em>i
</em>), the rebase is run in interactive
1423 <div class=
"paragraph"><p><strong>NOTE
</strong>: this is a possibly dangerous operation; do
<strong>not
</strong> use
1424 it unless you understand the implications (see
<a href=
"git-rebase.html">git-rebase(
1)
</a>
1425 for details).
</p></div>
1427 <dt class=
"hdlist1">
1428 branch.
<name
>.description
1432 Branch description, can be edited with
1433 <code>git branch --edit-description
</code>. Branch description is
1434 automatically added in the format-patch cover letter or
1435 request-pull summary.
1442 <h2 id=
"_examples">EXAMPLES
</h2>
1443 <div class=
"sectionbody">
1444 <div class=
"dlist"><dl>
1445 <dt class=
"hdlist1">
1446 Start development from a known tag
1449 <div class=
"listingblock">
1450 <div class=
"content">
1451 <pre><code>$ git clone git://git.kernel.org/pub/scm/.../linux-
2.6 my2.6
1453 $ git branch my2.6
.14 v2.6
.14 <b><1></b>
1454 $ git switch my2.6
.14</code></pre>
1456 <div class=
"colist arabic"><ol>
1459 This step and the next one could be combined into a single step with
1460 "checkout -b my2.6.14 v2.6.14".
1465 <dt class=
"hdlist1">
1466 Delete an unneeded branch
1469 <div class=
"listingblock">
1470 <div class=
"content">
1471 <pre><code>$ git clone git://git.kernel.org/.../git.git my.git
1473 $ git branch -d -r origin/todo origin/html origin/man
<b><1></b>
1474 $ git branch -D test
<b><2></b></code></pre>
1476 <div class=
"colist arabic"><ol>
1479 Delete the remote-tracking branches
"todo",
"html" and
"man". The next
1480 <em>fetch
</em> or
<em>pull
</em> will create them again unless you configure them not to.
1481 See
<a href=
"git-fetch.html">git-fetch(
1)
</a>.
1486 Delete the
"test" branch even if the
"master" branch (or whichever branch
1487 is currently checked out) does not have all commits from the test branch.
1492 <dt class=
"hdlist1">
1493 Listing branches from a specific remote
1496 <div class=
"listingblock">
1497 <div class=
"content">
1498 <pre><code>$ git branch -r -l '
<remote
>/
<pattern
>'
<b><1></b>
1499 $ git for-each-ref 'refs/remotes/
<remote
>/
<pattern
>'
<b><2></b></code></pre>
1501 <div class=
"colist arabic"><ol>
1504 Using
<code>-a
</code> would conflate
<remote
> with any local branches you happen to
1505 have been prefixed with the same
<remote
> pattern.
1510 <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>
1516 <div class=
"paragraph"><p>Patterns will normally need quoting.
</p></div>
1520 <h2 id=
"_notes">NOTES
</h2>
1521 <div class=
"sectionbody">
1522 <div class=
"paragraph"><p>If you are creating a branch that you want to switch to immediately,
1523 it is easier to use the
"git switch" command with its
<code>-c
</code> option to
1524 do the same thing with a single command.
</p></div>
1525 <div class=
"paragraph"><p>The options
<code>--contains
</code>,
<code>--no-contains
</code>,
<code>--merged
</code> and
<code>--no-merged
</code>
1526 serve four related but different purposes:
</p></div>
1527 <div class=
"ulist"><ul>
1530 <code>--contains
<commit
></code> is used to find all branches which will need
1531 special attention if
<commit
> were to be rebased or amended, since those
1532 branches contain the specified
<commit
>.
1537 <code>--no-contains
<commit
></code> is the inverse of that, i.e. branches that don
’t
1538 contain the specified
<commit
>.
1543 <code>--merged
</code> is used to find all branches which can be safely deleted,
1544 since those branches are fully contained by HEAD.
1549 <code>--no-merged
</code> is used to find branches which are candidates for merging
1550 into HEAD, since those branches are not fully contained by HEAD.
1554 <div class=
"paragraph"><p>When combining multiple
<code>--contains
</code> and
<code>--no-contains
</code> filters, only
1555 references that contain at least one of the
<code>--contains
</code> commits and
1556 contain none of the
<code>--no-contains
</code> commits are shown.
</p></div>
1557 <div class=
"paragraph"><p>When combining multiple
<code>--merged
</code> and
<code>--no-merged
</code> filters, only
1558 references that are reachable from at least one of the
<code>--merged
</code>
1559 commits and from none of the
<code>--no-merged
</code> commits are shown.
</p></div>
1563 <h2 id=
"_see_also">SEE ALSO
</h2>
1564 <div class=
"sectionbody">
1565 <div class=
"paragraph"><p><a href=
"git-check-ref-format.html">git-check-ref-format(
1)
</a>,
1566 <a href=
"git-fetch.html">git-fetch(
1)
</a>,
1567 <a href=
"git-remote.html">git-remote(
1)
</a>,
1568 <a href=
"user-manual.html#what-is-a-branch">“Understanding history: What is
1569 a branch?
”</a> in the Git User
’s Manual.
</p></div>
1573 <h2 id=
"_git">GIT
</h2>
1574 <div class=
"sectionbody">
1575 <div class=
"paragraph"><p>Part of the
<a href=
"git.html">git(
1)
</a> suite
</p></div>
1579 <div id=
"footnotes"><hr /></div>
1581 <div id=
"footer-text">
1583 2022-
09-
15 05:
23:
11 JST